Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to properly validate date-local in yii2?
Good afternoon, there was such a question, how to correctly implement date-local validation in yii2?
public function rules()
{
return [
[['date_notification'], 'date', 'format' => 'php:Y-m-d\TH:m'],
[['date_add'], 'safe'],
];
}
Answer the question
In order to leave comments, you need to log in
Didn't understand anything from the description. If you want to get an intelligible answer, learn how to compose the right question.
The date format is incorrect:
(most likely it should be 'php:Y-m-d\TH:i'
)
If you want the data not to be empty - add:
add a default value:
Perhaps it falls with an Exception for empty data, because the database does not provide a default value for the field date_notification
and is set to NOT NULL.
So call your grandmother.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question