Difference between #13 and #14 of
Cheat Sheet: Displaying Name instead of Numbers and Displaying Alphanumeric instead of numeric values

Changes

Title unchanged

Cheat Sheet: Displaying Name instead of Numbers and Displaying Alphanumeric instead of numeric values

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

relations, relational dropdown, binary to name, name instead of id, name instead of number, name instead of binary

Content changed

[...]
```php
array('name'=>'gender', 'value'=>'$data->gender? "Male": "Female"'),

```

 
actual model file under protected/models
 
 
search:
 
 
please see the bottom for this part! I can't get the search to search name instead of number.
you could also do something like this if you want a simple dropdown on your cgridview in your filter header:
 
 
 
```php 
array(
 
'name'=>'active_status', // 
 
'type'=>'raw',
 
'value' =>'$data->active_status? "Active": "Inactive"', //converts my 1 and 0 to Active / Inactive
 
'filter' => array('0' => 'Inactive', '1' => 'Active'), // Adds a dropdown to the filter
 
'headerHtmlOptions' => array('style'=>'text-align:center; vertical-align: middle;font-size: 20px !important;'),
 
'htmlOptions'=>array('style'=>'text-align:center; vertical-align: middle;')
 
),
 
```
 
 
actual model file under protected/models




This part is if your models **ARE** related.
--------------------------------------------
[...]
3 1
6 followers
Viewed: 59 813 times
Version: 1.1
Category: How-tos
Written by: skworden
Last updated by: skworden
Created on: Nov 4, 2012
Last updated: 11 years ago
Update Article

Revisions

View all history