The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist fourclub/yii2-editable "*"
or add
"fourclub/yii2-editable": "*"
to the require section of your composer.json.
In your gridview columns section
[
'class' => EditableColumn::className(),
'attribute' => 'username',
'url' => ['change-username'],
],
And add to your controller
public function actions()
{
return [
'change-username' => [
'class' => EditableAction::className(),
'modelClass' => UserModel::className(),
'forceCreate' => false
]
];
}
As a widget with a model
\fourclub\editable\Editable::widget( [
'model' => $model,
'attribute' => 'firstName',
'url' => '/profile/update'
]);
With ActiveForm
echo $form->field($model, "firstName")->widget(\fourclub\editable\Editable::className(), [
'url' => '/profile/update',
'mode' => 'popup'
]);
Comments