[eluser]jprateragg[/eluser]
While in the midst of converting my existing application to the CI framework, I've run into another stumbling block. One of the modules in my application allows me to bulk edit items. Here is my view:
Code:
foreach($cash_flow as $key => $value) {
?>
<tr>
<td><?php echo $j; ?>
<td><input type="checkbox" name="delete[<?php echo $value->id; ?>]" value="1" /></td>
<td><?php echo $value->cat_desc; ?></td>
<td><input type="text" name="historical[<?php echo $value->id; ?>]" value="<?php echo set_value('historical['. $value->id .']', $value->historical); ?>" /></td>
<td><input type="text" name="projected[<?php echo $value->id; ?>]" value="<?php echo set_value('projected['. $value->id .']', $value->projected); ?>" /></td>
<td><input type="text" name="adjusted[<?php echo $value->id; ?>]" value="<?php echo set_value('adjusted['. $value->id .']', $value->adjusted); ?>" /></td>
</tr>
<?php
echo form_hidden('cash_flow_category_id['. $value->id .']', $value->cash_flow_category_id);
$j++;
}
The value contained in $value->id is the unique id of the record being edited.
How would I use this in conjunction with $this->form_validation->set_rules? How can I set messages for which record/row need to be fixed? I tried this:
Code:
$arr = $this->input->post('cash_flow_category_id');
foreach($arr as $key) {
$this->form_validation->set_rules('cash_flow_category_id['. $key .']', 'Cash Flow Category', 'required|clean_int|cash_flow_check_values');
$this->form_validation->set_rules('historical['. $key .']', 'Historical Value', 'default_zero|clean_dec');
$this->form_validation->set_rules('projected['. $key .']', 'Projected Value', 'default_zero|clean_dec');
$this->form_validation->set_rules('adjusted['. $key .']', 'Adjusted Value', 'default_zero|clean_dec|greater_than[11000]');
}
But I don't get any errors returned for the last rule (greater than 11,000) when I have several rows with values below that. I appreciate any help. Thanks!