AR relation handling on Insert scenario

I am using like this


<?php echo $form->label($model->details,'utility_acct_no'); ?>

as you see here there is $model->details->utility_acct_no, but this doesn’t exists when the form is for new record (insert scenario)

How to fix it?

use like that:

<?php echo $form->label(new Detail,‘utility_acct_no’); ?>

Anyway if you are going to collect data from more model, you should have a model for detail too.

Take a look at this wiki.

But how to use this on textField where I need to save field to the column given by the relation something like $post->author->name=‘name’


<?php echo $form->textField($model->details,'utility_acct_no',array('size'=>30,'maxlength'=>30)); ?>

$model->details doesn’t exists here when insert scenario.