Hi guys,
I have a problem and I am new to Yii so perhaps I am doing something completely ridiculous , but bear with me.
I have a structure like this
class object extends CActiveRecord{
protected $object_type;
public function rules(){
return array('object_type', 'required');
}
}
class object_text extends object {
protected $position;
public function rules(){
return array_merge(parent::rules(),array(
array('position','required'),
));
}
}
I use
$text_object->setAttributes(...);
to set attributes and when I print_r $text_object it seems to be a nice Active Record object with attributes filled in.
Now I would like to run a validator on it and save it.
When I try using $text_object->save(); I get validation errors like this:
Array ( [object_type] => Array ( [0] => Object Type cannot be blank. ) [position] => Array ([0] => Position can not be blank))
If I remove rules, it passes but wont save…
Now what is it that I am doing wrong?
I will add that my goal is to have one table object and say 2 models : text and image, with some properties and methods identical and some unique (which I suppose is a purpose of inheritance) [Optionally I am considering 2 tables but still same structure of classes - whichever will be easier/more proper].
Any thoughts?