Open iSynth opened 8 years ago
It seems may be like this
<?= $form->field($model, 'done_till')->widget(DatePicker::className(),
[
'inline' => true,
'template' => '<div class="well" style="background-color: #fff; width:250px">{input}</div>',
'language' => 'ru',
'clientOptions' => [
'autoclose' => true,
'format' => new JsExpression('{
toDisplay: function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() - 7);
return d.toISOString();
},
toValue: function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() + 7);
return new Date(d);
}
}'),
]
]
);?>
or like this
<?= $form->field($model, 'done_till')->widget(DatePicker::className(),
[
'inline' => true,
'template' => '<div class="well" style="background-color: #fff; width:250px">{input}</div>',
'language' => 'ru',
'clientOptions' => [
'autoclose' => true,
'format' => [
'toDisplay' => new JsExpression('function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() - 7);
return d.toISOString();
}'),
'toValue' => new JsExpression('function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() + 7);
return new Date(d);
}')
]
]
]
);?>
But it doesn't work. Any ideas?
@re8us what is the response on your browser? can we have a look at the javascript code rendered?
@tonydspaniard sure
jQuery(document).ready(function () {
;jQuery('#task-deadline').parent().datepicker({"autoclose":true,"format":"dd.mm.yyyy","class":"col-md-3","language":"ru"});
;jQuery('#task-done_till').parent().datepicker({"autoclose":true,"format":{
toDisplay: function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() - 7);
return d.toISOString();
},
toValue: function (date, format, language) {
var d = new Date(date);
d.setDate(d.getDate() + 7);
return new Date(d);
}
},"language":"ru"});
;jQuery('#task-done_till').parent().on('changeDate', function (e){ jQuery('#task-done_till').val(e.format());});
jQuery('#w0').yiiActiveForm([{"id":"task-sum","name":"sum","container":".field-task-sum","input":"#task-sum","error":".help-block.help-block-error","validate":function (attribute, value, messages, deferred, $form) {yii.validation.number(value, messages, {"pattern":/^\s*[+-]?\d+\s*$/,"message":"Значение «Сумма» должно быть целым числом.","skipOnEmpty":1});}}], []);
});
and error
Thanks! checking
How to use this - http://bootstrap-datepicker.readthedocs.org/en/v1.6.0/options.html#format ?