Retrieve Model Validation Error Messages with Ajax |
Hello !
I use Codeigniter 4 model with some validation rules and messages using protected $validationRules and $validationMessages (https://codeigniter4.github.io/userguide...ating-data). I want to retrieve error messages on update but I don't succeed whereas the model respect the rules correctly (no effective update into the database if the rule isn't respected). I tried this kind of thing in my Controller wich is called by an "ajax-javascript" function : PHP Code: (...) Here is what I get when I'm not respecting the model's rule (and then there's no update so it's working, but I just want to retrieve the error message recorded in my model) : Code: <!-- DEBUG-VIEW START 1 SYSTEMPATH\Validation\Views\list.php --> Thanks ! I find the solution (few lines lower in the doc) .... if ($model->save($data) === false) { return view('updateUser', ['errors' => $model->errors()]); } |
Welcome Guest, Not a member yet? Register Sign In |