(09-15-2022, 07:31 PM)kenjis Wrote: > My question is why existing array in $this->model->errors() gone, replaced by item its supposed being added into existing array.
What do you mean?
$model->errors() returns the validation errors if the validation errors exist.
Thank you so much for the answer.
$this->model->errors() not gone, I try to add item on it (appended), with push a new item.
So, in my case, some field mandatory with condition, like field height, for example. Only mandatory (required) if other field, lets say checkbox checked then this field height required otherwise no (if that checkbox unchecked).
And also maybe other different form, like some form have height field, and other not.
So, this slightly code that I been trying to do.
PHP Code:
$errors = $this->model->errors();
if($this->request->getPost('checkbox') == true && $this->request->getPost('height') == '') {
$errors['height'] = 'Height must be filled.'
}
But, what I got was the whole errors replaced by only item height. Not appended.
Why is that?
Anyway thank you so much