Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Codeigniter, how to pass a third parameter to a callback (form validation)?

I am currently using the Form Validation class (on Codeigniter) and setting rules.

It works like this with two parameters (codeigniter.com/user_guide/libraries/form_validation.html):

$this->form_validation->set_rules('username', 'Username', 'callback_test[abc]');

But what about a third parameter? And a fourth...? Is it possible?

like image 980
Dacobah Avatar asked Jan 05 '12 10:01

Dacobah


1 Answers

It is not official but works

Split the parameter by ','

$this->form_validation->set_rules('article_big_image','Gambar Besar','callback_check_picture[article_big_image,edit]');

function check_picture($image,$param){
    $param = preg_split('/,/', $param);
    $field = $param[0];
    $action = $param[1];
    echo $field.$action;
}
like image 78
Andhri Hermawan Effendi Avatar answered Oct 25 '22 05:10

Andhri Hermawan Effendi