Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 verify a form checkbox is checked in twig template
    primarykey
    data
    text
    <p>I have a problem of verify a check box in twig template. In twig, i wanna to do this:</p> <pre><code>{% for activity in form.activity %} {% if (activity.isChecked) %} &lt;div&gt; {{ form_widget(activity) }} {{ form_label(activity) }} &lt;/div&gt; {% endif %} {% endfor %} </code></pre> <p>The activity is a entity field in form builder:</p> <pre><code>-&gt;add('activity', 'entity', array( 'class' =&gt; 'AcmeProspectionBundle:Activity', 'expanded' =&gt; true, 'multiple' =&gt; true, 'property' =&gt; 'name', /* 'query_builder' =&gt; function(EntityRepository $er) use($options) { return $er-&gt;createQueryBuilder('ac') -&gt;leftJoin('ac.company','c') -&gt;where('c = :id') -&gt;orderBy('ac.name', 'ASC') -&gt;setParameter('id', $options['company_id']); } */ )) </code></pre> <p>In fact, if I do not comment the <em>query_builder</em> part, it will only generate the checked part, but if I do this Symfony will check the integrity of the original array and the submit array. I can not add any new activity. In fact I generate the choice by javascript like this:</p> <pre><code> &lt;div class="activity_checkbox" data-prototype='&lt;div&gt; &lt;input type="checkbox" checked="checked" value="100" placeholder="" name="acme_prospection_company[activity][]"&gt; &lt;label&gt;&lt;/label&gt;&lt;/div&gt;'&gt; </code></pre> <p>Cause I have more than 3000 choice and I can not use the original checkbox or select to let user do that. So now all the work is done, only need to render the checked activities. And I do not know how.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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