Hi all,
I am facing problem in validating model field. I want to validate field ‘on’ scenarios.
I have below code with me.
class Images extends CActiveRecord
{
public $image;
public $scan_type;
public $testing_field;
public function rules()
{
return array(
array('testing_field,image_name, hide, category', 'required'),
array('image', 'file', 'types'=>'jpg, gif, png'),
array('image', 'required','on'=>'create'),
array('scan_type', 'required','on'=>'scan'),
array('height, width, size, type, created_on, hide, category', 'numerical', 'integerOnly'=>true),
array('image_path', 'length', 'max'=>55),
array('image_name', 'length', 'max'=>30),
array('id, image_name, height, width, size, type, created_on, hide, category, pagination', 'safe', 'on'=>'search'),
);
}
}
I have two custom fields to this model(testing_field,image) where as testing_field is validating for all the scenarios because i haven’t kept any on scenario, but my image field should validate only on create scenario where as it is not validating on create scenario. Could some one help me out where actually i am doing mistake.