Commit 68714cc8 by Carsten Brandt

ignore invalid date format and just display value as is

fixes #5155
parent 222f9ddf
......@@ -8,6 +8,7 @@
namespace yii\jui;
use Yii;
use yii\base\InvalidParamException;
use yii\helpers\FormatConverter;
use yii\helpers\Html;
use yii\helpers\Json;
......@@ -154,7 +155,12 @@ class DatePicker extends InputWidget
$value = $this->value;
}
if ($value !== null) {
$value = Yii::$app->formatter->asDate($value, $this->dateFormat);
// 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
}
}
$options = $this->options;
$options['value'] = $value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment