wbraganca / yii2-dynamicform

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

Kartik Date Pickers only show at row 1 #247

Open push32 opened 6 years ago

push32 commented 6 years ago

Kartik Date Picker Widget only show at row 1

i've tried to update the the datepicker to kvDatepicker but still not solve the issue, hope anyone guide me

nrob81 commented 6 years ago

Same issue for me.

mtangoo commented 6 years ago

I have found a better maintained fork here. Since this repo looks like abandoned, then I suggest you try asking the same question there.

nrob81 commented 6 years ago

Thank you, I'll check it out

theD1360 commented 6 years ago

@nrob81 has the forked version resolved your issue? I'm experiencing the same problems with this lib.

nrob81 commented 6 years ago

@theD1360 yes.

racielbd commented 5 years ago

can someone place the solution to the problem in this issue... i got the same one thanks

sdelfi commented 2 years ago

The following piece of code solved this problem for me:

jQuery(function ($) {
    // Fix dynamic form widgets
    $('[data-dynamicform]').each(function (k, form) {
        $(form).on('afterInsert', function (e, widgetOptionsRoot) {
            // "kartik-v/yii2-widget-datetimepicker"
            var $hasDateTimepicker = $(widgetOptionsRoot).find('[data-krajee-kvdatetimepicker]');
            if ($hasDateTimepicker.length > 0) {
                $hasDateTimepicker.each(function () {
                    $(this).parent().removeData().datetimepicker('remove');
                    $(this)
                        .parent()
                        .datetimepicker(eval($(this).attr('data-krajee-kvdatetimepicker')));
                });
            }

            // "kartik-v/yii2-widget-datepicker"
            var $hasDatepicker = $(widgetOptionsRoot).find('[data-krajee-kvdatepicker]');
            if ($hasDatepicker.length > 0) {
                $hasDatepicker.each(function () {
                    $(this).parent().removeData().kvDatepicker('destroy');
                    $(this)
                        .parent()
                        .kvDatepicker(eval($(this).attr('data-krajee-kvdatepicker')));
                });
            }

            // "kartik-v/yii2-widget-timepicker"
            var $hasTimepicker = $(widgetOptionsRoot).find('[data-krajee-timepicker]');
            if ($hasTimepicker.length > 0) {
                $hasTimepicker.each(function () {
                    $(this).removeData().off();
                    $(this).parent().find('.bootstrap-timepicker-widget').remove();
                    $(this).unbind();
                    $(this).timepicker(eval($(this).attr('data-krajee-timepicker')));
                });
            }
        });
    });
});