-
-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
type:bugBugBug
Description
What steps will reproduce the problem?
You create a form and you set the date format to 'dateFormat' => 'php:d/m/Y',
.
Then you click the input and select 1 august 2020, and you get 01/08/2020 with the format specified, everything good.
The problem is if you then submit the form and stay on the same page (ej: some form validation fails), the widget will get 01/08/2020
value from the form and then re-format it, as it is here:
https://github.com/yiisoft/yii2-jui/blob/master/src/DatePicker.php#L179
if ($value !== null && $value !== '') {
// format value according to dateFormat
try {
$value = Yii::$app->formatter->asDate($value, $this->dateFormat);
} catch(InvalidParamException $e) {
// ignore exception and keep original value if it is not a valid date
}
}
And you end up with this date in the input: 08/01/2020
.
My feedback:
It looks like I have to manually reparse the date value to a different format, eg: Y-m-d
, before rendering the datepicker after the model has been filled with post data.
What's expected?
To keep 01/08/2020
.
What do you get instead?
Re-formatted date 08/01/2020
.
Additional info
Q | A |
---|---|
Yii vesion | 2.0.29 |
PHP version | 7.3.6 |
Operating system | Windows |
Metadata
Metadata
Assignees
Labels
type:bugBugBug