Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple activecheckboxlists in yii from the same model on the same page
    primarykey
    data
    text
    <p>I have a pages with multiple activeCheckBoxLists which are actually generated in a foreach loop. The issue that I am having is that each list is generated with the same name's and id's as every other generated list. I need a way to either send an iteration or something into the id's and name's so that they are unique.</p> <p>When I use jquery to select the first item of the list it selects the first item of every list.</p> <p>Here is the code that generates the lists.</p> <pre><code>// collect all filter titles (level == 0, parent == 0) $topLevelFilterTitles = $hsf-&gt;findAllByAttributes(array('level'=&gt;'0','parent_id'=&gt;'0')); foreach($topLevelFilterTitles as $filterTitle): // with each filter title find all children (level == 1, parent == filter title id) echo "&lt;div class='half menu split'&gt;"; echo "&lt;p class='uppercase-text filter-name'&gt;" . $filterTitle-&gt;title . "&lt;/p&gt;"; $filterOptions = $hsf-&gt;findAllByAttributes( array( 'level'=&gt;'1', 'parent_id'=&gt;$filterTitle-&gt;id, ) ); $list = CHtml::listData($filterOptions,'filter_name','title'); echo CHtml::activeCheckBoxList( $hsf, // model 'filter_name', $list ); echo "&lt;/div&gt;"; endforeach; </code></pre> <p>The generated lists show up as follows</p> <pre><code>&lt;div class="halfmenu split"&gt; &lt;p class="uppercase-text filter-name"&gt;Filter Name R&lt;/p&gt; &lt;input id="ytHardwareSearchFiltering_filter_name" type="hidden" value="" name="HardwareSearchFiltering[filter_name]" /&gt; &lt;input id="HardwareSearchFiltering_filter_name_0" value="r_value0" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /&gt; &lt;label for="HardwareSearchFiltering_filter_name_0"&gt;r_name0&lt;/label&gt;&lt;br/&gt; &lt;input id="HardwareSearchFiltering_filter_name_1" value="r_value1" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /&gt; &lt;label for="HardwareSearchFiltering_filter_name_1"&gt;r_name1&lt;/label&gt; &lt;/div&gt; &lt;div class="halfmenu split"&gt; &lt;p class="uppercase-text filter-name"&gt;Filter Name T&lt;/p&gt; &lt;input id="ytHardwareSearchFiltering_filter_name" type="hidden" value="" name="HardwareSearchFiltering[filter_name]" /&gt; &lt;input id="HardwareSearchFiltering_filter_name_0" value="t_value0" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /&gt; &lt;label for="HardwareSearchFiltering_filter_name_0"&gt;t_name0&lt;/label&gt;&lt;br/&gt; &lt;input id="HardwareSearchFiltering_filter_name_1" value="t_value1" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /&gt; &lt;label for="HardwareSearchFiltering_filter_name_1"&gt;t_name1&lt;/label&gt;&lt;br/&gt; &lt;/div&gt; </code></pre> <p>I need (preferably) the ID to be different between lists, but even if I could get the name different that would be a start. Thanks in advance for the help.</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