views:

78

answers:

2

Hi! I have a form that contains checkboxes.

<input type="checkbox" name="question[5][13]" value="1" />

Now, I want to use the Kohana validation class, but it seems like it does not validate fields that are array... had anyone ever worked something around?

I have something like this, but it will not work:

$rules->rule('question[5][13]', 'not_empty');
+2  A: 

There's nothing to work around, if you're having an array than you're supposed to validate it's values, not only one value, right?

So, if you have a 'question' key in your values that are supposed to be validated, you should probably make a callback with custom validation for it, right?

so..

$validation_object->callback('question', 'validate_question_method');

... should probably do the job, as long as you validate all questions or whatever properly in the callback.

Kemo
A: 

The current Kohana 3 validation classes (3.0.7) can only validate the whole array as one item. You will have to use a custom callback to validate the whole array yourself as Kemo suggested.

The devs are looking at overhauling the validation classes, but I'm not sure if this is one of the things they're considering.

Formo 2 is planning to support this sort of form, but I'm not sure how close to completion this part is.

Lethargy