I am having a problem with the dateValidator.
Yii::$app->params[‘datePickerFormat’] = ‘mm/dd/yyyy’;
[['birth_date', 'aniversary_date', 'hire_date'], 'default', 'value' => null],
[['birth_date'], 'date',
'format' => Yii::$app->params['datePickerFormat'],
'timestampAttribute' => 'birth_date',
],
[['aniversary_date'], 'date',
'format' => Yii::$app->params['datePickerFormat'],
'timestampAttribute' => 'aniversary_date',
],
always give me the current month/correct day/correct year for both attributes in the DetailView.
DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' =>'birth_date',
'format'=>['date', 'php:F jS'],
],
'aniversary_date:date',
],
]);
The value of Yii::$app->params[‘datePickerFormat’] is what is needed for the dosamigos\datepicker\DatePicker.
$form->field($model, 'birth_date')->widget(DatePicker::className(), [
'options' => [
'placeholder' => Yii::$app->params['datePickerFormat'],
],
'clientOptions' => [
'autoclose' => true,
'format' => Yii::$app->params['datePickerFormat'],
//'startDate' => '-1d',
'clearBtn' => true,
'todayBtn' => true,
'todayHighlight' => true,
]
]);
If I take out the ‘format’=> in the rule, the date fails to validate. I even tried to use ‘php:’.Yii::$app->params[‘datePickerFormat’] in the rule[] and still fails to validate.
However when I go back to the form the dates are correct. What am I doing wrong? Any help would be appreciated.