wbraganca / yii2-dynamicform

It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.
Other
436 stars 439 forks source link

howto custom datecontrol date format at row2 and other #276

Open odevtheair opened 5 years ago

odevtheair commented 5 years ago

i want to chang format date from default config(m/d/y) to -> format(yyyy-mm-dd) it cannot in my config the first row it can format(yyyy-mm-dd) but row2 and later cannot in type format config *** Input saved as: not show too. error

mycode

_form.php

                <?

echo $form->field($modelHouse, "[{$indexHouse}]description")->widget(DateControl::classname(), [ 'type' => 'date', 'ajaxConversion' => true, 'autoWidget' => true, 'widgetClass' => '', 'displayFormat' => 'php:Y-m-d', 'saveFormat' => 'php:Y-m-d', 'saveTimezone' => 'UTC', 'displayTimezone' => 'Asia/Bangkok', 'saveOptions' => [ 'label' => 'Input saved as: ', 'type' => 'text', //'readonly' => true, //'class' => 'hint-input text-muted' ], 'widgetOptions' => [ 'pluginOptions' => [ 'autoclose' => true, 'format' => 'php:Y-m-d' ] ] ]);

                /*$form->field($modelHouse, "[{$indexHouse}]description")->widget(
                    yii\jui\DatePicker::className(),['clientOptions' => ['defaultDate' => '2014-01-01']]
                );*/

                ?>

myconfig

`'datecontrol' => [ 'class' => 'kartik\datecontrol\Module',

    // format settings for displaying each date attribute (ICU format example)
    'displaySettings' => [
        Module::FORMAT_DATE => 'yyyy-MM-dd',
        Module::FORMAT_TIME => 'HH:mm:ss a',
        Module::FORMAT_DATETIME => 'yyyy-MM-dd HH:mm:ss a', 
    ],

    // format settings for saving each date attribute (PHP format example)
    'saveSettings' => [
        Module::FORMAT_DATE => 'php:U', // saves as unix timestamp
        Module::FORMAT_TIME => 'php:H:i:s',
        Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
    ],

    // set your display timezone
    'displayTimezone' => 'Asia/Bangkok',

    // set your timezone for date saved to db
    'saveTimezone' => 'UTC',

    // automatically use kartik\widgets for each of the above formats
    'autoWidget' => true,

    // use ajax conversion for processing dates from display format to save format.
    'ajaxConversion' => true,

    // default settings for each widget from kartik\widgets used when autoWidget is true
    'autoWidgetSettings' => [
        Module::FORMAT_DATE => ['type'=>2, 'pluginOptions'=>['autoclose'=>true]], // example
        Module::FORMAT_DATETIME => [], // setup if needed
        Module::FORMAT_TIME => [], // setup if needed
    ],

    // custom widget settings that will be used to render the date input instead of kartik\widgets,
    // this will be used when autoWidget is set to false at module or widget level.
    'widgetSettings' => [
        Module::FORMAT_DATE => [
            'class' => 'yii\jui\DatePicker', // example
            'options' => [
                'dateFormat' => 'php:Y-m-d',
                'options' => ['class'=>'form-control'],
            ]
        ]
    ]
    // other settings
],`