forms and relations

Is there a way a CActiveForm to have a field of a model that have a relation to a model?

<?php $form=$this->beginWidget('CActiveForm', array(



)); ?>


	<div class="row">

		<?php echo $form->label($model,'cats->NAME'); ?>//cats has a relation with //that model

		<?php echo $form->textField($model,'cats->NAME'); ?>


If I not wrong you can use this way:

<?php echo $form->textField($model,'cats.NAME'); ?>

Where cats MUST BE the name of the relation (declared in relations()).

And of course NAME must be a property (field) of the related model.

nope. Didn’t work for me for some reason.

I have a relation with the name "user", I tried to access the described way. The label worked fine, but once I tried to pull the same trick with the TextField, I got an error "property "Offer.user.gender" is not defined."

<?php echo $form->label($model,'user.gender'); ?>

<?php echo $form->textField($model,'user.gender'); ?>

Somehow, the label function considered it to be defined whereas the textField one thought the opposite