-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
With simple config
// config:
'formatter' => [
'class' => 'yii\i18n\Formatter',
// 'dateFormat' => 'php:d-M-Y',
'dateFormat' => 'dd.MM.yyyy',
],
// model rules():
['published_at', 'date', 'timestampAttribute' => 'published_at'],
// widget:
$form->field($model, 'published_at')->widget(DatePicker::className(), [
'options' => ['class' => 'form-control'],
])
everything works ok, but if 'dateFormat' of formatter will be changed to, for example 'php:d-M-Y' datePicker widget starts handle different with DateValidator formatting, so posted value will never pass validation.
if alternately set up 'format' for model rule and same format as 'dataFormat' for DatePicker widget to avoid using global formatter values, anyways it will handle format 'php:d-M-Y' incorrectly. Client script looks like:
$('#post-published_at').datepicker($.extend({}, $.datepicker.regional['ru'], {"dateFormat":"dd-M-yy"}));
and when form with existent data loads, then data shown (for russian locale) as "19-мая-2016" but when I changed date - it shown as "18-Май-2016". so it has different form of nouns for month and obviously format is not same.
I am not sure it is real bug, but looks like some date format won't be handled correctly as described.
Additional info
| component | version |
|---|---|
| Yii vesion | 2.0.8 |
| PHP version | 7.0.4 |
| Operating system | Ubuntu xenial |