Skip to content

Instantly share code, notes, and snippets.

@schmunk42
Forked from cornernote/README.md
Last active Aug 29, 2015
Embed
What would you like to do?
<?php
use cornernote\giitools\helpers\TabPadding;
use yii\helpers\VarDumper;
\Yii::$container->set('\app\gii\giiant\crud\providers\DateTimeProvider', [
'columnNames' => ['scheduled_at','type', 'status'],
]);
\Yii::$container->set('\app\gii\giiant\crud\providers\RelationProvider', [
'inputWidget' => 'select2', // didnt work ?
]);
/**
* Index Page
*/
$columnFormats = [
// Job.type
'Job.type' => function ($attribute, $generator) {
return <<<INPUT
[
'attribute' => '{$attribute->name}',
'format' => 'raw',
'value' => function (\$model) {
return \$model->getTypeLabel();
},
]
INPUT;
},
// Job.status
'Job.status' => function ($attribute, $generator) {
return <<<INPUT
[
'attribute' => '{$attribute->name}',
'format' => 'raw',
'value' => function (\$model) {
return \$model->getStatusLabel();
},
]
INPUT;
},
// Job.address
'.*\.address$|.*\.notes$' => function ($attribute, $generator) {
return <<<INPUT
[
'attribute' => '{$attribute->name}',
'format' => 'ntext',
]
INPUT;
},
];
/**
* View Page
*/
$attributeFormats = [
// Job.type
'Job.type' => function ($attribute, $generator) {
return <<<INPUT
[
'format' => 'html',
'attribute' => '{$attribute->name}',
'value' => \$model->getTypeLabel(),
]
INPUT;
},
// Job.status
'Job.status' => function ($attribute, $generator) {
return <<<INPUT
[
'format' => 'html',
'attribute' => '{$attribute->name}',
'value' => \$model->getStatusLabel(),
]
INPUT;
},
// address
'.*\.address$|.*\.notes$' => function ($attribute, $generator) {
return <<<INPUT
[
'format' => 'ntext',
'attribute' => '{$attribute->name}',
]
INPUT;
},
];
/**
* Form Page
*/
$activeFields = [
// 'Job.type' => function ($attribute, $generator) {
// $data = TabPadding::pad(VarDumper::export(['pickup' => Yii::t('app', 'Pickup'), 'delivery' => Yii::t('app', 'Delivery')]));
// return <<<INPUT
//\$form->field(\$model, '{$attribute->name}')->radioList({$data});
//INPUT;
// },
'.*\.address$|.*\.notes$' => function ($attribute, $generator) {
return <<<INPUT
\$form->field(\$model, '{$attribute->name}')->textarea();
INPUT;
},
];
\Yii::$container->set('schmunk42\giiant\crud\providers\CallbackProvider', [
'columnFormats' => $columnFormats,
'attributeFormats' => $attributeFormats,
'activeFields' => $activeFields,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment