2017 © Pedro Peláez
 

yii2-extension yii2-mdh

Yii2 helper form PHP MDH

image

rangelreale/yii2-mdh

Yii2 helper form PHP MDH

  • Monday, March 26, 2018
  • by RangelReale
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 helpers for PHP Multi Data Handler

This library contains helpers for using the Multi Data Handler (MDH) library with Yii2., (*1)

Usage

Add the mdh application component to the web.php file., (*2)

    'mdh' => [
        'class' => 'app\components\MDH',
    ],

Optionally, you can replace the formatter to the MDH one., (*3)

    'formatter' => [
        'class' => 'RangelReale\yii2mdh\Formatter',
    ],

Then you can access MDH using the syntax:, (*4)

    Yii::$app->mdh->format('user', 'datetime', time());

Using in Yii2 components

Use \RangelReale\yii2mdh\Formatter with the 'converterFrom' property to automatically convert the data from any converter to the 'user'. You can also set the target conververt using the 'converter' property., (*5)

echo GridView::widget([
    'dataProvider' => $dataProvider,
    'formatter' => new \RangelReale\yii2mdh\Formatter(['converterFrom'=>'db']),
    'columns' => [
        'id',
        'name',
        [
            'attribute' => 'dt_add',
            'format' => 'datetime',
        ],
        [
            'attribute' => 'dt',
            'format' => 'date',
        ],
        [
            'attribute' => 'tm',
            'format' => 'time',
        ],
        [
            'attribute' => 'is_person',
            'format' => 'boolean',
        ],
        [
            'attribute' => 'duration',
            'format' => 'timeperiod',
        ],
    ],
]);

ArrayDataProvider

This DataProvider automatically converts values between formats., (*6)

$dataProvider = new \RangelReale\yii2mdh\ArrayDataProvider([
    'allModels' => $data,
    'key' => 'id',
    'converterFrom' => 'db',
    'converterTo' => 'user,
    'convert' => [
        'dt_add' => 'datetime',
        'dt' => 'date',
        'tm' => 'time',
        'is_user' => 'boolean',
        'duration' => 'timeperiod',
    ],
]);

Author

Rangel Reale, (*7)

The Versions

26/03 2018

dev-master

9999999-dev

Yii2 helper form PHP MDH

  Sources   Download

BSD-3-Clause

The Requires

 

by Rangel Reale

yii2 format