yiicod / yii2-editable

Editable widget and column for gridview.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yii2 Editable Widget

Renders a X-Editable Input allowing to use the amazing inline capabilities of X-Editable Plugin.

Latest Stable Version Total Downloads License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2mod/yii2-editable "*"

or add

"yii2mod/yii2-editable": "*"

to the require section of your composer.json.

Usage Editable column

  1. In your gridview columns section

Text column:

 [
    'class' => EditableColumn::className(),
    'attribute' => 'username',
    'url' => ['change-username'],
 ],

Select column:

[
    'class' => EditableColumn::className(),
    'attribute' => 'status',
    'url' => ['change-username'],
    'type' => 'select',
    'editableOptions' => function ($model) {
        return [
            'source' => [1 => 'Active', 2 => 'Deleted'],
            'value' => $model->status,
        ];
    },
],

Allowed column types: text, select, address, combodate, date, datetime

  1. And add to your controller
 public function actions()
      {
          return [
              'change-username' => [
                  'class' => EditableAction::className(),
                  'modelClass' => UserModel::className(),
                  'forceCreate' => false
              ]
          ];
      }

Usage Editable widget

  1. As a widget with a model
\yii2mod\editable\Editable::widget( [
    'model' => $model,
    'attribute' => 'firstName',
    'url' => '/profile/update'
]);
  1. With ActiveForm
echo $form->field($model, "firstName")->widget(\yii2mod\editable\Editable::className(), [
    'url' => '/profile/update',
    'mode' => 'popup'
]);

About

Editable widget and column for gridview.

License:MIT License


Languages

Language:PHP 100.0%