项目作者: yii2mod

项目描述 :
Editable widget and column for gridview.
高级语言: PHP
项目地址: git://github.com/yii2mod/yii2-editable.git
创建时间: 2014-11-29T21:19:28Z
项目社区:https://github.com/yii2mod/yii2-editable

开源协议:MIT License

下载






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
Build Status

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

  1. "yii2mod/yii2-editable": "*"

to the require section of your composer.json.

Usage Editable column

1) In your gridview columns section

Text column:

  1. [
  2. 'class' => EditableColumn::class,
  3. 'attribute' => 'username',
  4. 'url' => ['change-username'],
  5. ],

Select column:

  1. [
  2. 'class' => EditableColumn::class,
  3. 'attribute' => 'status',
  4. 'url' => ['change-username'],
  5. 'type' => 'select',
  6. 'editableOptions' => function ($model) {
  7. return [
  8. 'source' => [1 => 'Active', 2 => 'Deleted'],
  9. 'value' => $model->status,
  10. ];
  11. },
  12. ],

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

2) And add to your controller

  1. public function actions()
  2. {
  3. return [
  4. 'change-username' => [
  5. 'class' => EditableAction::class,
  6. 'modelClass' => UserModel::class,
  7. ],
  8. ];
  9. }

Usage Editable widget

1) As a widget with a model

  1. \yii2mod\editable\Editable::widget([
  2. 'model' => $model,
  3. 'attribute' => 'firstName',
  4. 'url' => '/profile/update',
  5. ]);

2) With ActiveForm

  1. echo $form->field($model, "firstName")->widget(\yii2mod\editable\Editable::class, [
  2. 'url' => '/profile/update',
  3. 'mode' => 'popup',
  4. ]);

Support us

Does your business depend on our contributions? Reach out and support us on Patreon.
All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.