Welcome Guest, Not a member yet? Register   Sign In
Form validation not working
#4

Hi,

I think i cracked this, so the example was modified as per below and it works:

PHP Code:
<?php
namespace App\Controllers;

use 
CodeIgniter\Controller;
use 
Config\Services;

class 
Form extends Controller {

 
   public $validation;

 
   public function index()
 
   {
 
       helper(['form''url']);

 
       $this->validation = \Config\Services::validation();

 
       $this->validation->setRules([
 
           'username' => 'required'
 
       ]);

 
       if (!$this->validation->withRequest($this->request)->run())
 
       {
 
           echo view('Signup', [
 
               'validation' => $this->validation
            
]);
 
       } else
 
       {
 
           echo view('Success');
 
       }
 
   }

Reply


Messages In This Thread
Form validation not working - by patelprem1992 - 02-11-2017, 08:39 AM
RE: Form validation not working - by albertleao - 02-11-2017, 11:12 AM
RE: Form validation not working - by donpwinston - 04-19-2017, 09:20 AM
RE: Form validation not working - by ciadmin - 04-19-2017, 10:01 AM
RE: Form validation not working - by donpwinston - 04-19-2017, 11:49 AM
RE: Form validation not working - by qury - 03-23-2017, 12:07 PM
RE: Form validation not working - by qury - 03-28-2017, 03:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB