Form validation in model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Form validation in model (/showthread.php?tid=75098) |
Form validation in model - muuucho - 12-20-2019 I am following the News tutorial and now I try to move the validation from the News controller/create() to the News model. Controller: PHP Code: <?php namespace App\Controllers; PHP Code: <?php namespace App\Models; The actual result is that I get the "Whoops" error when calling News/create() RE: Form validation in model - MGatner - 12-20-2019 Edit (or create) your .env file and set the environment to “development” - that will show you the actual error instead of the generic “Whoops” RE: Form validation in model - muuucho - 12-20-2019 (12-20-2019, 06:57 AM)MGatner Wrote: Edit (or create) your .env file and set the environment to “development” - that will show you the actual error instead of the generic “Whoops”I get "Argument 1 passed to url_title() must be of the type string, null given, called in C:\xampp\htdocs\ci4\app\Controllers\News.php on line 49". I think I must look for a POST before I run $model->save(). So I update my news/create() to: PHP Code: <?php namespace App\Controllers; Now I can insert new posts but if I submit an empty form, my validation error doesn't display. My view: PHP Code: <h2><?= esc($title); ?></h2> d in C:\xampp\htdocs\ci4\app\Controllers\News.php on line 49ng, null given, called in C:\xampp\htdocs\ci4\app\Controllers\News.php on line 49 RE: Form validation in model - Myster - 12-20-2019 Hi, Use $this->request->postVar for get your post input (Sorry for my very bad english, i'm French) RE: Form validation in model - muuucho - 12-20-2019 I changed my view to: (edit code) PHP Code: <h2><?= esc($title); ?></h2> |