hi.
I use kartik-crud-generator for generating crud views for table "dictionary".
I have issue with boolean field aktualne.
When I open dictionary/create page, field aktualne uses checkbox.
But when I open dictionary/update, this field uses text input.
Both views include the same _form.php file.
Is possible to use checkbox in both actions ?
_form.php:
<?php
use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
/**
* @var yii\web\View $this
* @var app\models\Dictionary $model
* @var yii\widgets\ActiveForm $form
*/
?>
<div class="dictionary-form">
<?php $form = ActiveForm::begin(['type'=>ActiveForm::TYPE_HORIZONTAL]); echo Form::widget([
'model' => $model,
'form' => $form,
'columns' => 1,
'attributes' => [
'nazwa'=>['type'=> Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter Nazwa...']],
'opis'=>['type'=> Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter Opis...']],
'data_wprowadzenia'=>[
'type'=> Form::INPUT_WIDGET,
'widgetClass'=>DateControl::classname(),
'options'=>['type'=>DateControl::FORMAT_DATE,'language'=>'pl','todayHighlight' => true,]
],
'aktualne'=>['type'=> Form::INPUT_CHECKBOX, 'options'=>['placeholder'=>'Enter Aktualne...']],
]
]);
echo Html::submitButton($model->isNewRecord ? 'Dodaj' : 'Zapisz', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
ActiveForm::end(); ?>
</div>
Changes in config.php:
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'generators' => ['kartikgii-crud' => ['class' => 'warrence\kartikgii\crud\Generator'],],
];
$config['modules']['gridview'] = ['class' => 'kartik\grid\Module',];
$config['modules']['datecontrol'] = [
'class' => 'kartik\datecontrol\Module',
// format settings for displaying each date attribute
'displaySettings' => ['date' => 'yyyy-MM-dd','time' => 'H:i:s A','datetime' => 'd-m-Y H:i:s A',],
// format settings for saving each date attribute
'saveSettings' => ['date' => 'yyyy-MM-dd','time' => 'H:i:s','datetime' => 'Y-m-d H:i:s',],
// automatically use kartik\widgets for each of the above formats
'autoWidget' => true,
];
}