Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to set unique date and date >= current day in validation rules?
Hello!
There are validation rules in the model:
[['object_id', 'release_date'], 'required'],
[['release_date'], 'date', 'format' => 'dd.MM.yyyy', 'timestampAttribute' => 'release_date'],
[['object_id'], 'integer'],
[['object_id', 'release_date'], 'unique',
'targetAttribute' => ['object_id', 'release_date']],
[['object_id'], 'exist', 'skipOnError' => true, 'targetClass' => Object::class, 'targetAttribute' => ['object_id' => 'id']],
echo $form->field($model, 'release_date')->widget(DatePicker::class, [
'clientOptions' => [
'minDate' => 'new Date()',
],
'dateFormat' => 'dd.MM.yyyy',
'options' => ['class' => 'form-control'],
])
Answer the question
In order to leave comments, you need to log in
It seems to me easier to write your validator in 3 lines:
https://www.yiiframework.com/doc/guide/2.0/en/inpu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question