PHP code example of veyselsahin / yii2-giix

1. Go to this page and download the library: Download veyselsahin/yii2-giix library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

veyselsahin / yii2-giix example snippets


\Yii::$container->set(
    'veyselsahin\giix\crud\providers\CallbackProvider',
    [

        'activeFields'  => [

           /**
            * Generate a checkbox for specific column (model attribute)
            */
           'common\models\Foo.isAvailable' => function ($attribute, $generator) {
               $data = \yii\helpers\VarDumper::export([0 => 'Nein', 1 => 'Ja']);
               return <<<INPUT
\$form->field(\$model, '{$attribute}')->checkbox({$data});
INPUT;
           },
        ],


        'columnFormats' => [

           /**
            * generate custom HTML in column
            */
           'common\models\Foo.html' => function ($attribute, $generator) {

               return <<<FORMAT
[
    'format' => 'html',
    'label'=>'FOOFOO',
    'attribute' => 'item_id',
    'value'=> function(\$model){
        return \yii\helpers\Html::a(\$model->bar,['/crud/item/view', 'id' => \$model->link_id]);
    }
]
FORMAT;
           },


           /**
            * hide all text fields in grid
            */
           '.+' => function ($column, $model) {
                    if ($column->dbType == 'text') {
                        return false;
                    }
           },

           /**
            * hide system fields in grid
            */
           'created_at$|updated_at$' => function () {
                   return false;
           },

        ]
    ]
);