dev-master
9999999-devAdd and update models in a modal window.
MIT
The Requires
- php >=5.4.0
- yiisoft/yii2 *
by Sergey Morozov
update yii2 editing modal add
Wallogit.com
2017 © Pedro Peláez
Add and update models in a modal window.
The preferred way to install this extension is through composer., (*1)
Either run, (*2)
composer require --prefer-dist sergmoro1/yii2-modal-crud, (*3)
or add, (*4)
"sergmoro1/yii2-modal-crud": "^1.0", (*5)
to the require section of your composer.json., (*6)
For example, there is a model Property with two fields: id, name., (*7)
namespace backend\controllers;
use sergmoro1\modal\controllers\ModalController;
use common\models\Property;
use common\models\PropertySearch;
class PropertyController extends ModalController
{
public function newModel() { return new Property(); }
public function newSearch() { return new PropertySearch(); }
}
Only matters index.php. Other are ordinary., (*8)
registerJs('var popUp = {"id": "property", "actions": ["update"]};', yii\web\View::POS_HEAD);
sergmoro1\modal\assets\PopUpAsset::register($this);
$this->title = Yii::t('app', 'Properties');
echo Modal::widget([
'id' => 'property-win',
'toggleButton' => false,
'header' => $this->title,
'footer' =>
''.
'',
]);
?>
// create action
= Html::a('glyphicon glyphicon-plus', ['create'], [
'id' => 'property-add',
'data-toggle' => 'modal',
'data-target' => '#property-win',
'class' => 'btn btn-success',
]) ?>
, (*9)
= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'id'
'name',
// update, delete actions
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'buttons' => [
'update' => function ($url, $model) {
return Html::a(
'',
$url, [
'class' => 'update',
'data-toggle' => 'modal',
'data-target' => '#property-win',
]
);
},
],
],
],
]); ?>
The entire code can be found at sergmoro1/yii2-lookup., (*10)
Add and update models in a modal window.
MIT
update yii2 editing modal add