Most of the time you don't need to create your own grid column types since the ones included in Yii are pretty flexible and are suitable for most use cases. Still, there are situations when you need to create a custom column.
Let's create a custom grid column that will allow a toggling Y/N value that will change the corresponding model value via AJAX.
Create a new application using
yiic webapp
as described in the official guide.Download the Sakila database from http://dev.mysql.com/doc/index-other.html. Execute the downloaded SQLs (first schema then data).
Configure the database connection in
protected/config/main.php
.Use Gii to create a model for the
customer
table.Open Gii, select Crud Generator and enter
Customer
into the Model Class field. Press Preview and then Generate.Gii will generate the controller in
protected/controllers/CustomerController.php
and a group of views underprotected/views/customer/
.Run the customer controller and go to the Manage...