![]() |
Retrieve Model Validation Error Messages with Ajax - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Retrieve Model Validation Error Messages with Ajax (/showthread.php?tid=79743) |
Retrieve Model Validation Error Messages with Ajax - the_steff - 07-25-2021 Hello ! I use Codeigniter 4 model with some validation rules and messages using protected $validationRules and $validationMessages (https://codeigniter4.github.io/userguide/models/model.html#validating-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()]); } |