Questions regarding relations w/ activeTextFields

Hi there,

is it possible to retrieve data from relational objects via the CHtml::active* Methods?

I tried

CHtml($myModel, '') 

which resulted in an error.

Looking at the code of CActiveRecord it seems not to be possible? What would be the correct approach here?

Writing this, it comes to my mind that

CHtml($myModel->relation, 'property') 

could work. But I don't like this, because I need to change all occurrences of 'relation' when this changes or a good refactoring tool.

The other thing I'd like to know is where to put business logic especially when this logic operates on multiple ActiveRecords.



What do you mean by "CHtml($myModel, '')"? This is not a valid PHP exp​ression anyway because CHtml is a class.

Sorry, I was not paying enough attention to the code.

What I meant was

CHtml::activeTextField($myModel, '');

where 'relation' is a relational property of myModel like an address for a person.

So one could translate this to

CHtml::activeTextField($person, 'address.street');

This is not supported, and I'm afraid we won't support it in future because it introduces too much code complexity, lowers performance, without much benefit.

As a workaround, you could pass 'address'=>$person->address to the view and therefore be able to use

CHtml::activeTextField($address, 'street');