Validating arrays


I have problem with validating arrays. I have model with two fields "key" and "value". I want validate CActiveForm from that model with custom array with datas e.g.:

$tmp = new Model;

$tmp->key = 'something';

$tmp->value = 'value';

$array[] = $tmp;

$tmp = new Model;

$tmp->key = 'different';

$tmp->value = 'value';

$array[] = $tmp;


echo CActiveForm::validate($array);

How can I do this?

You can do this:



// Do something


Take note that CActiveForm::validate($array) returns a JSON format, not a boolean:

You can use json_decode(CActiveForm::validate($array));