Skip to content

Instantly share code, notes, and snippets.

@schmunk42
Forked from cornernote/README.md
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmunk42/62edc6d31cb550929d01 to your computer and use it in GitHub Desktop.
Save schmunk42/62edc6d31cb550929d01 to your computer and use it in GitHub Desktop.
<?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