Reputation: 9123
I've got the following code to create a form in symfony2.
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('anne_stage_delete', array('id' => $id)))
->setMethod('DELETE')
->add('delete', 'submit')
->getForm()
;
}
But I can't find out how to add/change the name attribute. When I look in the rendered html the form name is form
.
Upvotes: 0
Views: 62
Reputation: 2776
Make the form name in twig
<form action="{{ path('yourpath') }}" method="post" name="your_name-form">
{{ form_widget(form) }}
</form>
Or
You can use createNamedBuilder
$form = $this->get('form.factory')->createNamedBuilder('your-custom-name', 'form', null, array(
'constraints' => $collectionConstraint,
))
->add('delete', 'submit')
->getForm();
Upvotes: 1