I want to save Task model, but cannot do it without define date.
I have boolean attribute allDay
(checkbox in view) and if it set in TRUE date format should be d-m-Y
; else 'd-m-Y H:m'.
How to define this condition in rules()
method?
Next code not work:
public function rules() {
return [
[['title', 'user_id'], 'required'],
[['description'], 'string'],
[['start', 'end'], 'date',
'format' => $this->allDay ? 'php:d-m-Y' : 'php:d-m-Y H:i'],
];
}