• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to handle form validation with bulk editing?

#2
[eluser]jprateragg[/eluser]
I found my mistake. When I ran my foreach, I need to use $key => $value instead of just $key--I didn't realize I did that.

Code:
$arr = $this->input->post('cash_flow_category_id');

foreach($arr as $key => $value) {
$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');
}

My other issue is I currently use a function, in this case "cash_flow_check_values", which checks the values of several fields. This is the current function:

Code:
public function cash_flow_check_values() {
if($this->ci->input->post('historical') == 0 and $this->ci->input->post('projected') == 0 and $this->ci->input->post('adjusted') == 0) {
  return false;
} else {
  return true;
}
}

How would I be able to do this through a bulk edit? I would have to know what key in the array I was on to set the appropriate field name. Any ideas? Thanks!


Messages In This Thread
How to handle form validation with bulk editing? - by El Forum - 12-05-2012, 02:25 PM
How to handle form validation with bulk editing? - by El Forum - 12-06-2012, 03:29 PM
How to handle form validation with bulk editing? - by El Forum - 12-06-2012, 05:32 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.