PHPackages                             antonyz89/yii2-templates - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. antonyz89/yii2-templates

ActiveYii2-extension[Templating &amp; Views](/categories/templating)

antonyz89/yii2-templates
========================

minor changes in model/crud templates

1.5.1(4y ago)22.0k11BSD-3-ClausePHPPHP &gt;=7.2

Since Feb 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AntonyZ89/yii2-templates)[ Packagist](https://packagist.org/packages/antonyz89/yii2-templates)[ RSS](/packages/antonyz89-yii2-templates/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (1)

yii2-templates
==============

[](#yii2-templates)

[ ![Donate with PayPal](https://camo.githubusercontent.com/648ad6f048733f167bf65e11a4fd759eef14da88db61ad078bbd5ddea5d57133/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YATHVT293SXDL&source=url)Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist antonyz89/yii2-templates dev-master

```

or add

```
"antonyz89/yii2-templates": "dev-master"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

**environments/dev/common/config/main**

and run `php init` again

```
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['bootstrap'] = ['gii'];
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'generators' => [
            'model' => [
                'class' => 'antonyz89\templates\model\Generator',
                'templates' => [
                    'default' => '@antonyz89/templates/model/default', // add default template
                ]
            ],
            'crud' => [
                'class' => 'antonyz89\templates\crud\Generator',
                'templates' => [
                    'admin-lte' => '@antonyz89/templates/crud/admin-lte', // add admin-lte template
                    'material-lite' => '@antonyz89/templates/crud/material-lite', // add material-lite template
                    'material-bootstrap' => '@antonyz89/templates/crud/material-bootstrap', // add material-bootstrap template
                    'default' => '@antonyz89/templates/crud/default', // add default template
                ]
            ]
        ],
    ];
}
```

Easy Pjax with `_search.php`
----------------------------

[](#easy-pjax-with-_searchphp)

**Kartik GridView ONLY**

CRUD generated by Gii with any template already do it, just add `YiiTemplateAsset` to complete

**Usage:**

1 - Just add `YiiTemplateAsset` on `YOUR_MODULE/assets/AppAsset`

```
use antonyz89\templates\assets\YiiTemplatesAsset;

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [];
    public $js = [];
    public $depends = [
        YiiTemplatesAsset::class // ADD
    ];
}
```

2 - Now, just enable `pjax` on GridView

```
GridView::widget([
    'dataProvider' => $dataProvider,
    'pjax' => true, // here
    'columns' => [
        'id',
        'name',
        [
            'class' => 'kartik\grid\ActionColumn',
            'width' => '150px',
            'buttonOptions' => [
                'class' => 'btn btn-sm btn-default'
            ],
            'updateOptions' => [
                'class' => 'btn btn-sm btn-primary'
            ],
            'deleteOptions' => [
                'class' => 'btn btn-sm btn-danger'
            ]
        ]
    ]
]);
```

3 - Add `data-ajax => true` on \_search's form

```
