kartik-v / yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)
Other
105 stars 54 forks source link

init with new js object properties #116

Open strtob opened 1 year ago

strtob commented 1 year ago

Hi,

I use the great kartik widgets, in my case datecontrol:

 <?=
            $form->field($model, 'end')->widget(\kartik\datecontrol\DateControl::classname(), [
                'type'           => \kartik\datecontrol\DateControl::FORMAT_DATETIME,
                'saveFormat'     => 'php:Y-m-d H:i:s',
                'ajaxConversion' => true,
                'options'        => [
                    'pluginOptions' => [
                        'placeholder' => Yii::t('app', 'Start'),
                        'autoclose'   => true,
                    ]
                ],
            ]);
            ?>

Depend on a checkbox, I would like the format to something without time.

via js, I've got the krajee js objects:

var dateControl = $('#event-end-disp').data('krajee-datetimepicker');
var dateTimePicker = $('#event-end-disp').data('krajee-datecontrol');

console.log(dateControl);
console.log(dateTimePicker);

The properties displayFormat e.g. are possible to change to 'dd.mm.yyyy'. But now it's seams that I have to init the widgets again and haven't found any function like init() to do that.

Any help would be very much appreciated!

Thanks a lot! Tobi

strtob commented 1 year ago

is there another way to swap between datepicker and datetimepicker with js? in my case in calendar (all day event)