Welcome Guest, Not a member yet? Register   Sign In
Issue with form validation
#6

(This post was last modified: 09-30-2018, 11:40 AM by unodepiera.)

(09-30-2018, 03:57 AM)InsiteFX Wrote: This has to do with the News Tutorial. Try that and tell me what you get.

You are right InsiteFX, the documentation is wrong, the validation accept an array of rules, but $this->request is an object, this works:

PHP Code:
public function create()
{
 
   helper('form');
 
   $model = new \App\Models\News();

 
   if (! $this->validate([
 
       'title' => 'required|min[3]|max[255]',
 
       'text'  => 'required'
 
   ]))
 
   {
 
       echo view('templates/header', ['title' => 'Create a news item']);
 
       echo view('news/create');
 
       echo view('templates/footer');

 
   }
 
   else
    
{
 
       $model->save([
 
           'title' => $this->request->getVar('title'),
 
           'slug'  => url_title($this->request->getVar('title')),
 
           'text'  => $this->request->getVar('text'),
 
       ]);
 
       echo view('news/success');
 
   }

Reply


Messages In This Thread
Issue with form validation - by happyape - 09-27-2018, 12:47 AM
RE: Issue with form validation - by InsiteFX - 09-27-2018, 04:04 AM
RE: Issue with form validation - by happyape - 09-27-2018, 05:32 AM
RE: Issue with form validation - by unodepiera - 09-30-2018, 12:26 AM
RE: Issue with form validation - by InsiteFX - 09-30-2018, 03:57 AM
RE: Issue with form validation - by unodepiera - 09-30-2018, 10:48 AM
RE: Issue with form validation - by happyape - 09-30-2018, 02:46 PM
RE: Issue with form validation - by unodepiera - 09-30-2018, 10:47 PM
RE: Issue with form validation - by happyape - 10-01-2018, 12:47 AM
RE: Issue with form validation - by unodepiera - 10-01-2018, 01:18 AM
RE: Issue with form validation - by happyape - 10-01-2018, 01:55 AM
RE: Issue with form validation - by dave friend - 10-01-2018, 09:16 AM
RE: Issue with form validation - by InsiteFX - 10-01-2018, 10:40 AM
RE: Issue with form validation - by dave friend - 10-01-2018, 11:05 AM
RE: Issue with form validation - by InsiteFX - 10-01-2018, 12:08 PM
RE: Issue with form validation - by Ekley - 10-11-2019, 07:22 AM
RE: Issue with form validation - by Bart Goossens - 08-22-2020, 08:58 AM
RE: Issue with form validation - by jreklund - 08-22-2020, 12:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB