Welcome Guest, Not a member yet? Register   Sign In
Creating validation for a checkbox array.
#1

[eluser]Bramme[/eluser]
Okay, in my form I have a series of checkboxes called categories[] so I can process them as an array in my controller.

However, there's no validation for this in CI 1.6.3 (is there in 1.7? if so, i'm upgrading) so I thought I'd write my own.

Code:
$rules['categories[]'] = 'callback_required_checkbox';
That's in my controller

and in MY_Validation.php I have
Code:
function required_checkbox($str) {

    $ci =& get_instance();
    
    $ci->validation->set_message('require_array_checkbox', 'You have to set at least one checkbox');
        
    if( $ci->input->post($str) == '') {
        return FALSE;
    } else {
        return TRUE;
    }
}
However, nothing happens. I'd even be happy with an error message, but not even that! Unless I delete a ; offcourse. If I try to echo something in it, nothing happens either...

Can anybody help me out?


Messages In This Thread
Creating validation for a checkbox array. - by El Forum - 09-12-2008, 06:04 AM
Creating validation for a checkbox array. - by El Forum - 09-12-2008, 06:20 AM
Creating validation for a checkbox array. - by El Forum - 09-12-2008, 06:38 AM
Creating validation for a checkbox array. - by El Forum - 09-26-2008, 12:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB