ajaxcrudgiitemplate Gii CRUD template for Single Page Ajax Administration.

  2. Overview
  3. Requirements
  4. Installation
  5. Usage


You may want to check first the latest behavior driven version of this extension,ajax-crud-behavior.This is an outdated extension.


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.


  • Hide index.php from your requests,if you have'nt done so yet.You can find detailed instructions on how to do this here.(Paragraph 6) Also,in urlManager configuration in config/main.php file set
  • Unzip the downloaded file.
  • Copy the gii folder to your application's protected folder.
  • Copy the js_plugins folder to the root folder of your application,(same level as protected).
  • In config/main.php file,in gii configuration, add the path of your gii folder like so:
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
                    	'generatorPaths' => array(
                        'application.gii'  //Ajax Crud template path


  • Create the table for your model in the database.Use id as your primary key column name.
  • Click Model Generator.Type the table name in the Table Name field.
  • Preview if you want,and then Generate.
  • Your Model class has been generated.

  • Click Crud Generator
  • In the Model Class field type the name of the class that was generated in the previous step.
  • Click Code template and select ajax_crud,if it's not already selected.
  • Preview if you want,and then Generate.

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.


  • 1.3.December 11th 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.2.Deprecated

  • 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!

21 0
5 553 downloads
Yii Version: 1.1
License: MIT
Category: Database
Developed by: drumaddict
Created on: Nov 5, 2011
Last updated: 10 years ago


show all

Related Extensions