checkbox - Status of checkboxes submitted from symfony to twig -


I'm searching for a way to submit the contents of the checkboxes to a toggle template from a symphony controller. So that the user does not have to check again if the form was made incomplete and some more input is required.

For this reason that there are more than one checkbox in the form of an array, I am disturbing: an ID ({{usergroup.id}}) will be submitted and let me state the status of this ID Thought to use this number to check:

  {usergroup in usergroups%} in% & lt; Input type = "checkbox" name = "employee data" value = "{{usergroup.id}}" {% if check is {{usergroup.id}}%} check = "check" & gt; {& Amp; Endif%} & gt; {{Usergroup.name}} {% endfor%}  

Of course this is not working - like I hope :)

Can anyone give I get a signal that how it is working?

Edit: Here's the real situation: Output looks like a script here:. A selection box with nested checkboxes.

For this, I need to get all values ​​in the form of a checkbox, not as a choice. In fact, I am doing this by giving a new layout to block_choice_widget :)

  {% block choice_widget_collapsed -%} // ..... {% if empty_an none is -%} And lieutenant; Li & gt; & Lt; Label & gt; & Gt; Input type = "checkbox" {% if required and value is empty}% check = "checked" {% endif%} name = "employee member-user group" value = "{{user group .id}}" Gt; {{Empty_value | Trans ({}, translate_domain}}} & lt; / Label & gt; & Lt; / Li & gt; {% - endif%} // ...... {% - endblock choice_widget_collapsed%}  

This is working but it does not seem to be the best solution for me but as I'm new to Symphony, this is a work solution :) Is there a better way or the possibility of getting multiple checkboxes?

You can set the data option in the form builder to set the status of the check box Need to use; Here's one.

Sample code:

  $ manufacturer-> Add ('active', 'checkbox', array ('label' = & gt; 'active'? ',' Required '= & gt; wrong,' data '= & gt; $ entity- & gt; GetActive () ))  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -