[eluser]RBrowne[/eluser]
I'm trying to develop a form for storing the engineer distribution for a project. The form I have presently is as follows:
Code:
<h2>Projects » Add Engineer</h2>
<?php echo validation_errors(); ?>
<?php echo form_open('projects/add_engineers'); ?>
<table border="0" cellspacing="0" cellpadding="3">
<thead>
<tr>
<th>Engineers</th>
<th>Design</th>
<th>Planning</th>
<th>Construction</th>
<th>Commissioning</th>
</tr>
</thead>
<tbody>
<?php foreach ($aEngineers as $aEngineer) { ?>
<tr>
<td><?=$aEngineer['name']?></td>
<td align="center"><input type="checkbox" name="design[]" value="<?=$aEngineer['id']?>" <?=set_checkbox('design[]', $aEngineer['id'])?> /></td>
<td align="center"><input type="checkbox" name="planning[]" value="<?=$aEngineer['id']?>" <?=set_checkbox('planning[]', $aEngineer['id'])?> /></td>
<td align="center"><input type="checkbox" name="construction[]" value="<?=$aEngineer['id']?>" <?=set_checkbox('construction[]', $aEngineer['id'])?> /></td>
<td align="center"><input type="checkbox" name="connissioning[]" value="<?=$aEngineer['id']?>" <?=set_checkbox('connissioning[]', $aEngineer['id'])?> /></td>
</tr>
<?php } ?>
</tbody>
</table>
<p>
<input type='submit' value='Submit'/>
<input type='reset' value='Clear'/>
</p>
</form>
As you can see the checkboxes are generated based on the engineers array (a simple multidimensional array with Id and Name for each engineer). It produces the form perfectly.
My problem arises when it comes to validating and repopulating the form. The checkboxes are all returned without any being checked, which when there's 20 engineers, that's a lot of checkboxes to recheck.
Why is it that the set_checkbox() function doesn't seem to be working? And as a slight aside, why doesn't the set_radio() function not work in a similar situation?
Any help would be appreciated.