-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't work with kartik DateControl and DatePicker widget #41
Comments
looking forward to this bug fix |
looking to this bug fix |
The following fix is working for me. // "kartik-v/yii2-widget-datecontrol"
var $hasDateControl = $(this).find('[data-krajee-datecontrol]');
if ($hasDateControl.length > 0) {
$hasDateControl.each(function() {
var id = $(this).attr('id');
var dcElementOptions = eval($(this).attr('data-krajee-datecontrol'));
if (id.indexOf(dcElementOptions.idSave) < 0) {
// initialize the NEW DateControl element
var cdNewOptions = $.extend(true, {}, dcElementOptions);
cdNewOptions.idSave = $(this).next().attr('id');
$(this).kvDatepicker(eval($(this).attr('data-krajee-kvdatepicker')));
$(this).removeAttr('value name data-krajee-datecontrol');
$(this).datecontrol(cdNewOptions);
}
});
} |
@cloudcaptain // "kartik-v/yii2-widget-datecontrol"
var $hasDateControl = $(widgetOptionsRoot.widgetItem).find('[data-krajee-datecontrol]');
if ($hasDateControl.length > 0) {
$hasDateControl.each(function() {
var id = $(this).attr('id');
var dcElementOptions = eval($(this).attr('data-krajee-datecontrol'));
if (id.indexOf(dcElementOptions.idSave) < 0) {
// initialize the NEW DateControl element
var cdNewOptions = $.extend(true, {}, dcElementOptions);
cdNewOptions.idSave = $(this).parent().next().attr('id');
$(this).parent().datepicker(eval($(this).attr('data-krajee-datepicker')));
$(this).removeAttr('value name data-krajee-datecontrol');
$(this).datecontrol(cdNewOptions);
}
});
} I hope it is helpful to someone and that this bug will be corrected in yii2-dynamic-form.js |
Talking about only DatePicker widget, it seem that Kartik has changed attribute names, so code in [...]
var $hasDatepicker = $(widgetOptionsRoot.widgetItem).find('[data-krajee-datepicker]');
if ($hasDatepicker.length > 0) {
$hasDatepicker.each(function() {
$(this).parent().removeData().datepicker('remove');
$(this).parent().datepicker(eval($(this).attr('data-krajee-datepicker')));
});
}
[...] can't work anymore, because for example This way, someone else has already tried to solve the fix here; so I have tried to use the same fix and what happens in my case is this: the widget appears correctly, but the parsing of php format does not. This is my partial: echo DatePicker::widget([
'form' => $form,
'language' => Yii::$app->language,
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'model' => $model,
'attribute' => "[{$i}]birthday",
'convertFormat' => true,
'pluginOptions' => [
'endDate' => '+0d',
'autoclose' => true,
'format' => 'php:Y-m-d',
'todayHighlight' => true,
],
]); and when I click on a date on the calendar, year and day are correct, but month is not; for example, I click on I hope my informations can help someone to solve the problem. Thanks |
News: the date parsing error comes from Kartik exentions when DatePicker widget is called that way (because php date parsing is called twice, going to error), so changing to this: $picker = [
'language' => Yii::$app->language,
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'convertFormat' => true,
'pluginOptions' => [
'endDate' => '+0d',
'autoclose' => true,
'format' => 'php:Y-m-d',
'todayHighlight' => true,
],
];
echo $form->field($model, "[{$i}]birthday")->widget(DatePicker::className(), $picker); php parsing now works as espected. |
@Discomania great! @wbraganca, i confirm, this code is working. patch: --- yii2-dynamic-form.js.old 2015-08-11 23:27:48.273959445 +0800
+++ yii2-dynamic-form.js 2015-08-11 21:39:13.000000000 +0800
@@ -309,12 +309,30 @@
var _restoreSpecialJs = function(widgetOptions) {
var widgetOptionsRoot = _getWidgetOptionsRoot(widgetOptions);
+ // "kartik-v/yii2-widget-datecontrol"
+ var $hasDateControl = $(widgetOptionsRoot.widgetItem).find('[data-krajee-datecontrol]');
+ if ($hasDateControl.length > 0) {
+ $hasDateControl.each(function() {
+ var id = $(this).attr('id');
+ var dcElementOptions = eval($(this).attr('data-krajee-datecontrol'));
+ if (id.indexOf(dcElementOptions.idSave) < 0) {
+ // initialize the NEW DateControl element
+ var cdNewOptions = $.extend(true, {}, dcElementOptions);
+ cdNewOptions.idSave = $(this).parent().next().attr('id');
+ $(this).parent().kvDatepicker(eval($(this).attr('data-krajee-kvdatepicker')));
+ $(this).removeAttr('value name data-krajee-datecontrol');
+ $(this).datecontrol(cdNewOptions);
+
+ }
+ });
+ }
+
// "kartik-v/yii2-widget-datepicker"
- var $hasDatepicker = $(widgetOptionsRoot.widgetItem).find('[data-krajee-datepicker]');
+ var $hasDatepicker = $(widgetOptionsRoot.widgetItem).find('[data-krajee-kvdatepicker]');
if ($hasDatepicker.length > 0) {
$hasDatepicker.each(function() {
- $(this).parent().removeData().datepicker('remove');
- $(this).parent().datepicker(eval($(this).attr('data-krajee-datepicker')));
+ $(this).parent().removeData().kvDatepicker('remove');
+ $(this).parent().kvDatepicker(eval($(this).attr('data-krajee-kvdatepicker')));
});
}
|
Anyone have a solution for this problem? My datepicker doesnt work (after add new item), i'm using kartik\date\DatePicker, i made the changes, but the problem continues.. Anyone have another solution? |
here is working solution for date picker and datetimepicker kartik 's widget
|
https://github.com/kartik-v/yii2-datecontrol
...
$interval): ?>Add
....
.....
After dynamic add DateControl and set date indicates an error that field is not filled.
possible to find a solution?
The text was updated successfully, but these errors were encountered: