Hi,
Presume a very basic form with a list part like this:
<?php echo CHtml::activeDropDownList($model, 'customer_id', CHtml::encodeArray(CHtml::listData(Customer::model()->findAll(), 'id', 'first_name'))); ?>
Let's say we need to make the text attribute in the list consist of both first_name and last_name from the Customer model. What is the recommended/Yii way to do that?
Searching the forums it looks doable either by giving a manual criteria to the model argument of listData (which would feel a bit misplaced, maybe a scope or something would be nicer), or by the addition of an extra field on the model in question. If the latter case is the preferred one, what changes would be needed to the model?
Thanks!
Presume a very basic form with a list part like this:
<?php echo CHtml::activeDropDownList($model, 'customer_id', CHtml::encodeArray(CHtml::listData(Customer::model()->findAll(), 'id', 'first_name'))); ?>
Let's say we need to make the text attribute in the list consist of both first_name and last_name from the Customer model. What is the recommended/Yii way to do that?
Searching the forums it looks doable either by giving a manual criteria to the model argument of listData (which would feel a bit misplaced, maybe a scope or something would be nicer), or by the addition of an extra field on the model in question. If the latter case is the preferred one, what changes would be needed to the model?
Thanks!