2
symfony2에서 양식 필드를 미리 채 웁니다. URL은 내가 여기사용 양식 미리 채우기 데이터 가져 오기
6. 형태로 projectId을 설정 해주기 원하는이
http://localhost/Symfony/web/app_dev.php/clearance/new?projectId=6
처럼 보이는 것은 내 컨트롤러 코드
public function newclearanceAction(){
$request = $this->getRequest();
$id = $request->query->get('projectId');
echo $id; //this works, but how to send it to the form?????
$clearance = new Clearance();
$form = $this->createForm(new ClearanceType(), $clearance);
if ($request->getMethod() == 'POST'){
$form->bindRequest($request);
if($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($clearance);
$em->flush();
return $this->redirect($this->generateUrl('MyReportBundle_project_list'));
}
}
return $this->render('MyReportBundle:Clearance:new.html.twig',array('form'=>$form->createView()));
입니다 그리고 여기 형태로보기
코드입니다<form action="{{ path('MyReportBundle_clearance_new') }}" method="post" >
{{ form_errors(form) }}
{{ form_rest(form) }}
<input type="submit" />
</form>
어떤 도움을 주셔서 감사합니다!
GREAT! 그게 효과가 있었어 :-) – mbs
다행 이었어. 확장 성을위한 편집을 추가했습니다. 만약 내가 당신에게 도움이 될 수 있다면 그것을 조언 할 것입니다. – Luke
매핑 된 필드가 작동하지 않는 것 같습니다. 권리 ? – Hpatoio