I have got a problem with the id generation of Symfony Widgets.
(I am new to symfony so I might have made some mistakes.)
At work we used
$form->render();
to render a form but this gave us not enough control over the table layout.
So I had to break up the rendering process and build the table by hand.
I am now using
$Form['<cellname>']->render();
for rendering the single widgets.
But with the new rendering i get wrong id’s for my widgets.
The form is used to track the share of a single user for the completion of a project per year.
The ids with the old methode were all in the form of
project_<CustomIdforDifferentYears>_<UserId>_share
but now I get
project_year_member_share
for all fields.
Symfony automatically generates the id of your widgets based on few things.
First is the form name which can be specified like below:
Now every widget’s id in that form will be prefixed with “my_form”.
The rest comes from the widget name. So if the widget name is ’email’, your widget’s id will be generated as “my_form_email”.
If want to specify the widget’s id in the template. You can do this also as part of the render method, which accepts an array of options like this: