Am I doing something wrong?
If I call CActiveForm->labelEx, which ultimately calls CHtml::resolveName, and $model refers to an array of objects (because it’s a HAS_MANY relation), then of course get_class fails. What should I be doing in this case?
Am I doing something wrong?
If I call CActiveForm->labelEx, which ultimately calls CHtml::resolveName, and $model refers to an array of objects (because it’s a HAS_MANY relation), then of course get_class fails. What should I be doing in this case?
Hi Heyho,
what exactly you want to do?
Given
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'emails' => array(self::HAS_MANY, 'Email', 'person_id'),
// etc.
I would like to get the label related to that relation. Using $model->emails causes problems because the framework assumes if it is getting passed a model it must be individual one. So, ok, knowing it is an array I could pass $model->emails[0] but then what should I do if there are no elements in the array? The whole concept seems messed up.
Hi again,
did you check this?
$form->labelEx($model, 'emails.theAttributeThatYouWant');
where $model->emails[x]->theAttributeThatYouWant label exists as attribute even instance emails is null