I'm struggling to achieve a similar admin view as in http://www.yiiframew....php/post/admin (the blog demo). In the demo, after the post/admin view is rendered, all the posts in the system are shown and the drop down list for the status doesn't have any item as 'selected' (in the <option> tag).
I've managed to put a similar view together, but the only problem I'm having is that I can't see all the users in my user admin view, as in a drop down list of filter options, one of them is selected and is filtering the CGridView from the beginning. Which I don't want.
My 'profile/admin' view looks like this:
<?php $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'profile-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns'=>array( 'id', array( 'name' => 'username', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->username), array("profile/view", "id" => $data->id))', ), array( 'name' => 'email', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->email), "mailto:" . $data->email)', ), array( 'name' => 'createtime', 'type' => 'datetime', 'filter' => false ), array( 'name' => 'lastvisit', 'type' => 'datetime', 'filter' => false ), array( 'name' => 'status', 'value' => '$data->itemAlias("UserStatus", $data->status)', 'filter' => $model->itemAlias('UserStatus') //'filter'=> false ), array( 'name' => 'superuser', 'value' => '$data->itemAlias("AdminStatus", $data->superuser)', 'filter' => $model->itemAlias('AdminStatus') //'filter'=> false ), array( 'class'=>'CButtonColumn' ) ) )); ?>
The itemAlias method works similarly to the one in the blog demo (Lookup::items). It returns an array in the form [Type][CodeInt] = Label, which applies human-readable labels to user status identified by an integer ('1' is Yes, '0' is No etc.). The main problem is that the option '0' is selected, as in the code:
<option value=""></option> <option value="0" selected="selected">No</option> <option value="1">Yes</option>
How is that possible? I really want the drop down list to not have any selected options, so that the Grid View could show all the users in the system when the admin view is accessed for the first time. To finish - I can say that filtering works, so if I select anything from the drop down list, the grid is updated.
Any help appreciated,
With kind regards,