php - Why is form-getData() empty? (Symfony2) -
there html form, whish contains email , password field. send controller action using post.
it works, if access inputs using $request->request->get('email')
this code doesn't works. $data
empty object reason:
$form = $this->createformbuilder() ->add('email', 'email') ->add('pass', 'text') ->getform(); $form->handlerequest($request); $data = $form->getdata(); return new response('email: '.$data['email']);
try this:
$form->get('email')->getdata();
in twig template:
<form action="{{ path('path-to-controller') }}" method="post"> {{ form_widget }} <input type="submit" value="send"/> </form>
Comments
Post a Comment