I have two tables: ‘Subscriptions’ and ‘Customers’, it’s a one to one relationship.
With the CGridView I want be able to search the ‘customer.Customernumber’ field.
For the moment it only shows the value of that field.
(The widget shows the ‘Subscriptions’ table with ‘Customers’ joined)
<?php $this->widget('zii.widgets.grid.CGridView', array(
Is this supported by the widget functionality?
Read in another topic on the same startpage for this forum, it did give me some information but not all, so the existence of this thread could still be useful.
Solved it like this:
[*]Added a new member to the Subscriptions table called ‘$aux_customerNumber’.
[*]Added ‘$aux_customerNumber’ to the safe attribute list (THIS WAS THE MISSING PART FROM THE OTHER THREAD)
[*]Added this to the search method in the model:
$criteria->addSearchCondition('customer.CustomerNumber', $this -> aux_customerNumber, true);
[*]This is how the column information is present in the view file:
'header' => 'Customer number',
'name' => 'aux_customerNumber',
'filter' => CHtml::activeTextField($model, 'aux_customerNumber'),
'value' => '$data -> customer -> CustomerNumber',