Skip to content
Advertisement

How to save formdata in a Database in Symfony when using no Formbuilder?

I’m developing a Symfony Bundle for Polls. I tried to build my Poll with the Symfony Form builder but i had so many Problems due to my complex data, that i decided to build my Form manually in the html File.


Is there now any possibility to still do something like that:

if($form->isSubmitted() && $form->isValid())?


Do i have to send my form to another php-File like that: <form method="post" action="yourscript.php"> or can i still catch it in my Controller, which also had the action for opening the poll-file in it.


Or do i have to do it as it is described here?

I’m sorry for this noob question but when i search for form control with Symfony i only find stuff that explaines how to use the formbuilder.

Advertisement

Answer

You can do something simillar to Form with Request.

if ($request->isMethod(Request::POST)) { //check if method is post
  $request->request->get('yourFieldName'); //get values of  post data
}

I advice you to use Symfony Form instead of this !

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement