I have a form with some text fields and I have a preview button that needs to submit the form to the same controller. And then in the controller, I need to extract the values and populate a form with these values for the template to see. What is the best way to achieve this? I’m a newbe so please be clear.
Share
Sample controller:
Use
<?php echo $form->renderFormTag( url_for('@yourRoutingName'), array('method' => 'POST') ); ?>in your template and change@yourRoutingNameto the one pointing to your controller.Now change your controller to be something like this:
The
$this->form->bind( $request->getParameter( $this->form->getName() ) );part binds posted data to your form where$this->form->isValid()returns a boolean whether the form is valid or not.