I have a form in Codeigniter with about 100 checkboxes. After validation, the set_value works fine for the first checkboxes, but not for the rest. Is there any limitation for the amount of set_values?
<label>
<?php
echo form_checkbox('indoor[]', '1', set_checkbox('indoor[]', 1)); ?>
Text 1
</label>
...
<label>
<?php
echo form_checkbox('indoor[]', '100', set_checkbox('indoor[]', 100)); ?>
Text 100
</label>
Bests, Yanick
The third parameter of form_check_box
requires a boolean value which determines whether checked attribute is added to the generated input.
Therefore, try this
<label>
<?php
echo form_checkbox('indoor[]', '1', in_array('1', set_value('indoor[]', []))); ?>
Text 1
</label>
...
<label>
<?php
echo form_checkbox('indoor[]', '100', in_array('100', set_value('indoor[]', []))); ?>
Text 100
</label>
You can replace the second parameter of set_value
with a persistent data for instance(depends on your implentattion). This will be returned by default if user hasn't submitted the form.