I have a problem as well with this functionality, But I am not as advanced as you :
I have a relation between model A and model B : A BELONGS_TO B
I write the method actionRegister in A’s controller :
$model=new A;
$company = new B;
if(isset($_POST['A'], $_POST['B']))
{
// populate input data to $a and $b
$model->attributes=$_POST['A'];
$company->attributes=$_POST['B'];
// validate BOTH $a and $b
$valid=$model->validate();
$valid=$company->validate() && $valid;
if($valid){
echo "SAVED";
}
$this->render('register',array(
'model'=>$model,
'company'=>$company
));
in my rules in A, I have :
array('firstName,lastName','required','on'=>'register')
and in the B’s model , I don’t have anything related to the A’s register action.
When I run the page, I got this error :
Property "CRequiredValidator.0" is not defined.
I have no idea on how to solve it, I tried to create validators specially for model B, and pass it into actionRegister lile that :
$model=new A('register');
and to combine all possibilities ( remove all validators concerning the actionRegister function ) and experimenting
B rules in B model file :
array('name','required','on'=>'A.register'),
//or in A's model
array('B.name','required','on'=>'register'),
with no luck, any ideas on how to get the form displaying?