You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases (see example below) DatePicker transforms invalid user input into invalid date. Instead exact invalid user input must remain in the field.
Example: Yii::$app->formatter->dateFormat is set to 'php:Y-m-d'
Date validator is set as: ['someDate', 'date']
DatePicker is rendered as: <?= $form->field($model, 'someDate')->widget(DatePicker::className()) ?>
When user enters value '1234567' into DatePicker input field and submits the form that input field incorrectly displays '1970-01-15' instead of original user input '1234567'. This happens because the following code tries to format value '1234567' using Yii::$app->formatter->asDate() which in turn tries to parse its first argument as UNIX timestamp value:
protectedfunction renderWidget()
{
// ..........if ($value !== null && $value !== '') {
// format value according to dateFormattry {
$value = Yii::$app->formatter->asDate($value, $this->dateFormat);
} catch(InvalidParamException$e) {
// ignore exception and keep original value if it is not a valid date
}
}
Don't know how to work around that problem and I think to fix it a significant redesign of DatePicker will be needed.
The text was updated successfully, but these errors were encountered:
In some cases (see example below) DatePicker transforms invalid user input into invalid date. Instead exact invalid user input must remain in the field.
Example:
Yii::$app->formatter->dateFormat
is set to'php:Y-m-d'
Date validator is set as:
['someDate', 'date']
DatePicker is rendered as:
<?= $form->field($model, 'someDate')->widget(DatePicker::className()) ?>
When user enters value '1234567' into DatePicker input field and submits the form that input field incorrectly displays '1970-01-15' instead of original user input '1234567'. This happens because the following code tries to format value '1234567' using
Yii::$app->formatter->asDate()
which in turn tries to parse its first argument as UNIX timestamp value:Don't know how to work around that problem and I think to fix it a significant redesign of DatePicker will be needed.
The text was updated successfully, but these errors were encountered: