Say I have an HTML form with a bunch of fields. Some fields belong to Product, some to Order, some to Other. When the form is submitted, I want to accept this request, and then create forms in Symfony for the product, order, and more. Then I want to get partial form data and bind it to the corresponding forms. An example would be something like this:
$productArray = array('name'=>$request->get('name'));
$pf = $this->createForm(new \MyBundle\Form\ProductType(), $product);
$pf->bind($productArray);
if($pf->isValid()) {
}
The fact is that when I try to do this, I can not get the $ form-> isValid () method. The bind () operation seems to fail. I have a suspicion that this may be related to the form token, but I'm not sure how to fix it. Again, I create my own HTML form in the view (I did not use form_widget (), causing all the difficulties it would take to combine a bunch of FormTypes into one of them). I just want a very simple way to use a basic HTML form with the Symfony form set of functions.
Can someone tell me that this is possible even with Symfony and how can I do this?
source
share