Answer the question
In order to leave comments, you need to log in
Form and validation from a third-party service. How to do it right?
Good afternoon.
There was such a problem.
I have two bundles in symfony2.
In the first bundle, a form is created in the controller and displayed on the page
. I want to make the controller accept form values in the second bundle.
First controller:
$form = $this->createFormBuilder($donut)
->add('sum','integer', array('label' => 'Сумма'
))
->getForm();
public function indexAction(Request $request)
{
$all_sum = $sum*70;
}
if ($request->getMethod() == 'POST') {
$form->bind($request);
Answer the question
In order to leave comments, you need to log in
The form is created in the first bundle, but (in this case) not used, but is used in the second bundle? That is, the form uses Request in the controller in the second bundle?
Make the form a separate service , don't use the form builder in the controller. This, by the way, is generally more convenient - first create a form, and in the controller create it via $form = $this->createForm('my_form');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question