javascript - symfony2 advanced select in form

Solution:
I had the same problem. I use jQuery to get part of the collection (extra input fields). In controller I have form builder that creates and returns those inputs as HTML. You can add condition and pass parameters (I use POST and GET is only for testing) and get different collection.
/**
* @Route("/gcco/{id}", name="name", options={"expose"=true})
* @Method({"GET", "POST"})
*/
public function functionName($id){
$defaultData = array('message' => 'Type here');
$form = $this->createFormBuilder($defaultData, array('csrf_protection' => false));
$form->add('name', 'type', array(
'label' => 'label',
'label_attr' => array(
'title' => 'title',
),
'required' => false,
));
}
}
$form = $form->getForm();
$html = $this->renderView('YourBundle:Default:form.html.twig', array('form' => $form->createView()));
return new JsonResponse(
array(
'html' => $html
)
);
}
And in form.html.twig file add so you will get only input fields:
{{ form_widget(form) }}
In JsonResponse you will get your collection.
Maybe it's not the best way but it works for me every time.
Other way is to pass JSON back to JavaScript and build all inputs there.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: use the option --with-all-dependencies (-w) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.