indifferend/yii2-editable

Yii2 editable field extension

Installs: 6

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

2.1 2021-06-02 11:33 UTC

This package is auto-updated.

Last update: 2024-05-09 20:29:51 UTC


README

993323

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

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

or add

"indifferend/yii2-editable": "*"

to the require section of your composer.json.

Usage Editable column

  1. In your gridview columns section

Text column:

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

Select column:

[
    'class' => EditableColumn::class,
    '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::class,
            'modelClass' => UserModel::class,
        ],
    ];
}

Usage Editable widget

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

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.