2017 © Pedro Peláez
 

yii2-extension yii2-modal-crud

Add and update models in a modal window.

image

sergmoro1/yii2-modal-crud

Add and update models in a modal window.

  • Friday, July 20, 2018
  • by sergmoro1
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 module for editing models table in a modal window

Installation

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)

Usage

For example, there is a model Property with two fields: id, name., (*7)

Controller

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(); }
}

View

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)

The Versions

20/07 2018

dev-master

9999999-dev

Add and update models in a modal window.

  Sources   Download

MIT

The Requires

 

by Sergey Morozov

update yii2 editing modal add