dev-master
9999999-devYii2 helper form PHP MDH
BSD-3-Clause
The Requires
by Rangel Reale
yii2 format
Yii2 helper form PHP MDH
This library contains helpers for using the Multi Data Handler (MDH) library with Yii2., (*1)
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());
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', ], ], ]);
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', ], ]);
Rangel Reale, (*7)
Yii2 helper form PHP MDH
BSD-3-Clause
yii2 format