Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 - How to put label and input for checkboxes/radios in a same line?
    primarykey
    data
    text
    <p>In my form I have some checkboxes, but by default, <b>I have</b> :</p> <ul> <li>the first radio widget</li> <li>the first label</li> <li>the second radio widget</li> <li>the label</li> </ul> <p>Here is the html code generated by SYmfony2 :</p> <pre><code> &lt;div&gt; &lt;input ...&gt; &lt;label ...&gt;&lt;/label&gt; &lt;input ...&gt; &lt;label ...&gt;&lt;/label&gt; &lt;/div&gt; </code></pre> <p>What <b>I want</b> is to have :<br/> <br/> the first radio widget the first label<br/> the second radio widget the second label <br/></p> <p>The html code would be :</p> <pre><code> &lt;label .....&gt;&lt;input ....&gt;&lt;/label&gt; </code></pre> <p>I think I have to override the choice_widget but don't know how to put input and label on the same line<br/></p> <p>Here is the choice_widget I may need to override :</p> <pre><code> {% block choice_widget %} {% spaceless %} {% if expanded %} &lt;div {{ block('widget_container_attributes') }}&gt; {% for child in form %} {{ form_widget(child) }} {{ form_label(child) }} {% endfor %} &lt;/div&gt; {% else %} &lt;select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}&gt; {% if empty_value is not none %} &lt;option value=""&gt;{{ empty_value|trans }}&lt;/option&gt; {% endif %} {% if preferred_choices|length &gt; 0 %} {% set options = preferred_choices %} {{ block('widget_choice_options') }} {% if choices|length &gt; 0 and separator is not none %} &lt;option disabled="disabled"&gt;{{ separator }}&lt;/option&gt; {% endif %} {% endif %} {% set options = choices %} {{ block('widget_choice_options') }} &lt;/select&gt; {% endif %} {% endspaceless %} {% endblock choice_widget %} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload