Skip to main content

Posts

Showing posts from August, 2013

YII CGRIDVIEW, Add form actions to cgridview

This is a tutorial for how to add input text-Field, check-box, buttons in CGridView. Scenario  This is  CRUD  pages for admin menu management. So, Menu model have following things: menuId : INT menuName : VARCHAR sortOrder : INT (Admin may change menu order, based on that front side menu will render) isActive : BOOL (only values with '1' will be shown in front side) isDelete : BOOL (only values with '0' will be shown, whenever admin deletes any menu value will be changed to '1') Demo  Below is how GRID will look like: Fetch listing from model:  Let's start with  model  file. There is only one change, I want default listing by sortOrder field. public function search ( ) { ..... return new CActiveDataProvider ( $this , array ( ' criteria ' => $criteria , ' sort ' => array ( ' defaultOrder ' => ' sortOrder ASC ' , ) , ) ) ; } Add TextField, checkbox, bu