• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Callbacks and array ?

#1
[eluser]quasiperfect[/eluser]
i use the latest https://github.com/EllisLab/CodeIgniter
i have in the controller
Code:
$this->load->library('form_validation');  $this->form_validation->set_rules('myarray[]', 'myarray', 'callback__myarray_check');
if ($this->form_validation->run() == FALSE)
{
}
else
{
}
$this->load->view('welcome_message');
the callback function is
Code:
function _myarray_check($str) {
print_r($str);
echo '|';
$this->form_validation->set_message('_myarray_check', 'myarrayerror');
return FALSE;
}

in the view
Code:
<form method="post" action="welcome/">
<input type="checkbox"  name="myarray[]" value="1"> a, <input type="checkbox" name="myarray[]" value="2"> b
<?php echo (form_error('myarray[]'))?(form_error('myarray[]')):('');?>
<input type="submit" value="test">
</form>

on submit i get 1|2|
so the callback is called for each value of the array
is this intended ?
is a bug ?
to me more logical would be to get the array as parameter and to execute the callback once

edit
if nothing is selected the callback is not even called


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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