开发者

need some help figuring out how to approach this validation

开发者 https://www.devze.com 2023-03-11 17:11 出处:网络
I am using codeigniter for my form validation.I have two select fields named parent_male a开发者_如何转开发nd parent_female.I would like to have a validation callback to check both the parent_male and

I am using codeigniter for my form validation. I have two select fields named parent_male a开发者_如何转开发nd parent_female. I would like to have a validation callback to check both the parent_male and parent_female in my database to see if it exists. I already have a previous callback function that does just that, but with only one field. I would like to check the two field values against the database, except I am not sure how to approach this idea. Any help/ideas are greatly appreciate! Thank you.

-Rich


You can define your callback as:

function isparent($parent) {
    $result = FALSE;
    /* do your stuff to check $parent is a valid parent and then ... */

    return $result;
} 

and the rules can be set as

$this->form_validation->set_rules('parent_male', 'Male parent', 'callback_isparent');
$this->form_validation->set_rules('parent_female', 'Female parent', 'callback_isparent'); 

In that way you use the same callback for both fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消