2
我使用CraueFormFlowBundle創建了一個多頁表單。通過這個表單,我可以創建一個新的實體對象或編輯一個現有對象。編輯現有實體時瀏覽CraueFormFlowBundle
我加入了設置
protected $allowDynamicStepNavigation = true;
允許使用表單編輯現有的對象我希望能夠直接跳轉到任何頁面在導航時來回形式的網頁,但是形成。這似乎不起作用 - 對象數據被加載,我可以反覆按下,直到我到達所需的頁面。
當使用CraueFormFlowBundle進行編輯時,有沒有辦法呈現頁面導航?
我的模板包括:
{% include 'CraueFormFlowBundle:FormFlow:stepList.html.twig' %}
創建導航。這裏是editAction:
public function editDriverAction($id) {
$em = $this->getDoctrine()->getManager();
$formData = $em->getRepository('NewgtDriverBundle:NewgtDriver')->find($id);
if (!$formData) {
throw $this->createNotFoundException('Unable to find Driver.');
}
//$formData = new NewgtDriver(); // Your form data class. Has to be an object, won't work properly with an array.
$flow = $this->get('newgtDriver.form.flow.createDriver'); // must match the flow's service id
$flow->bind($formData);
// form of the current step
$form = $flow->createForm();
if ($flow->isValid($form)) {
$flow->saveCurrentStepData($form);
if ($flow->nextStep()) {
// form for the next step
$form = $flow->createForm();
} else {
// flow finished
$em = $this->getDoctrine()->getManager();
$em->persist($formData);
$em->flush();
$flow->reset(); // remove step data from the session
return $this->redirect($this->generateUrl('driver')); // redirect when done
}
}
return $this->render('NewgtDriverBundle:Driver:new.html.twig', array(
'form' => $form->createView(),
'flow' => $flow,
));
}