I always thought that the navigation in the view files that the default gii CRUD generator creates is too complex. This CRUD gii template generates a single Administration page with a CGridView.Update/Create forms and model details view are rendered in a Fancybox Window and deletions go through a confirmation dialog (jUI).The form works with client validation(given that your model validation rules are included in the rules supported by the current Yii client validation).You can switch to Ajax Validation simply by setting the relevant option in CActiveForm instantiation in _ajax_form file,and uncommenting the performAjaxValidation call in ReturnForm action of the controller.
Developed and tested with Yii 1.8,may work with other versions too.
'modules'=>array( ...... 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'1', // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters'=>array('127.0.0.1','::1'), 'generatorPaths' => array( 'application.gii' //Ajax Crud template path ), ), ....... )
Your Model class has been generated.
Click Crud Generator
This is it.Navigate to the Administration page:go to [application root]/[controller ID]/.You should see the administration page and you are ready to perform CRUD operations on the model.
Spiros "drumaddict" Kabasakalis,November 5th 2011.
Form submission is now handled by jQuery Form Plugin (see resources). This has the advantage that you can include a file field in your form,and it will be submitted without a page refresh,although this is not technically ajax,(as the XHR object cannot handle this task). For more information see online jQuery Form Plugin documentation.
'afterAjaxUpdate' callback of CGridView now does not duplicate the code declared in the script tag. It just calls a js function declared in the script tag so unnecesssary code repetition has been eliminated.
Fancybox 2 is now used for the form rendering.Please see the licence for fancybox2 online.(resources).
1.1.November 9th 2011.
Made some changes so that the application root folder is not hardcoded in URLs,in generated views and controller. Now generated code is valid in local and production enviroment as well,without the need to manually change the URLs. Thanks to Asgaroth for pointing this out to me. Cheers!