Editing
Forms With Checkboxes For Each Entity in Symfony
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Template == <syntaxhighlight lang="twig"> {{ form_start(form) }} {{ form_errors(form) }} <button type="submit" class="btn btn-default" name="form[update]">save selected</button> {% for tutorial in tutorials %} {{ form_widget(form.tutorialId[loop.index0] ) }} {% endfor %} <button type="submit" class="btn btn-default" name="form[update]">save selected</button> {% do form.update.setRendered %}{# compensates for manually inserting this multiple times in the form #} {{ form_end(form) }} </syntaxhighlight> # The checkboxes are rendered with `form_widget()`. ## `tutorialId` corresponds to the index of the checkbox collection added to the form builder object. ## The individual checkboxes in the collection are accessed through a numeric index. Twig provides the `loop.index0` helper. # The html for the submit buttons are is manually inserted into the template. The Symfony helper functions will only render a form element once to avoid duplicate `id` values. # `form_end()` will render any fields that have not explicitly rendered in the form already. `form.update.setRendered` prevents this.
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information