Yii 1.1: w-create-dialog-bootstrap-base

creates a dialog box for forms using CJuiDialog for any controller
1 follower

WCreateDialog displays a dialog widget with create form using the given controller path. We can now use any controller provided that we change the controller's create function as mentioned below. WCreateDialog extends the CJuiDialog widget.

It simplifies the dialog creation process using the guide from http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model/

It Reduces all the work and you just have to amend controller yourself.

Requirements

...requirements of using this extension is Yii 1.1 or above ...This one depends upon bootstrap as it uses TbHtml Class a lot. You can either change the class to CHtml yourself or download the other extension

Usage

unpack the package to extension/webcare/widgets

To use this widget, you may insert the following code in a view:

$this->beginWidget('ext.webcare.widgets.WCreateDialog', array(// the dialog
     'id' => 'MyDialog',
     'linkText' => 'Create New MyClass', // The Button which is placed for opening the dialog
     'url' => array('controller/create'), // controller/action usually create
     'parentElementSelector' => '#selectElement',  // the parent select element in which the data returned will be populated
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Dialog box 1',
        'autoOpen'=>false,
    ),
));
$this->endWidget('ext.webcare.widgets.WCreateDialog');

Don't forget to change your controller's create action like the following

if ($model->save()) {
      if (Yii::app()->request->isAjaxRequest && Yii::app()->request->isPostRequest) {
          echo CJSON::encode(
                  array(
                      'status' => 'success',
                      'div' => 'MyClass Record successfully added',
                      'newObj' => array('id'=>$model->id,'value'=>$model->title),
                  )
          );
         Yii::app()->end();
     } else {
         $this->redirect(array('view', 'id' => $model->id));
     }
 }

And before the following code

$this->render('create', array(
      'model' => $model,
 ));

Add the following

if (Yii::app()->request->isAjaxRequest) {
   echo CJSON::encode(array(
     'status'=>'failure', 
     'div'=>$this->renderPartial('_form', array('model'=>$model), true)));
   Yii::app()->end();
 }

Resources

Total 2 comments

#19249 report it
Rehan Anis at 2015/04/27 01:17pm
@faild to use this extension

Sorry for late reply. The problem is you have downloaded the Bootstrap based version. Remove this version download again from the following link and install it.

http://www.yiiframework.com/extension/w-create-dialog-bootstrap-base/files/WCreateDialogSimple.zip

This will resolve your problem inshaAllah.

#19229 report it
saman123456 at 2015/04/24 05:05pm
faild to use this extension

i add code like above but to faild to use this extension and this error be " Error 500 include(TbHtml.php) [function.include]: failed to open stream: No such file or directory " please help me

Leave a comment

Please to leave your comment.

Create extension