Welcome Guest, Not a member yet? Register   Sign In
validation_errors
#1

Why the function validation_errors() in form helper does not work with In-Model Validation?
I must enter this in any controller to work: $this->session->setFlashdata('_ci_validation_errors', $model->errors());
Kind regards
Reply
#2

Ok. Probably because you use built-in validation. There is no need for it to be saved between sessions.

https://codeigniter4.github.io/userguide...ion-errors
Simple CI 4 project for beginners codeigniter-expenses
Reply
#3

(06-13-2024, 01:05 PM)elephpantech Wrote: Why the function validation_errors() in form helper does not work with In-Model Validation?

A Model has its own Validation instance. Because you can use many Models in a request.

For example,
If you have used two Models, there are two Validation instance.
validation_errors() checks the shared Validation instance by CI4 Services.
The shared Validation instance is a different instance from the Validation instances in the Models.

After all, there is no way that validation_errors() gets the Validation instance that you want to show the error.
Reply
#4

It was very clear, thank you
Good work!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB