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

How can I just verify my rules on a submit? I followed the User Guide. But it is not clear enough for me. Since I set my Rules even on the first load I get all the errors which makes sense. How can I avoid it in the CI4 way?

Here is the controller:

       
PHP Code:
helper(['form''url']);
$validation =  \Config\Services::validation();
    
        
        $validation
->setRules([
            'username' => ['label' => 'username''rules' => 'required|min_length[5]'],
            'password' => ['label' => 'password''rules' => 'required|min_length[5]']
        ]);

      
        
        
if ($validation->withRequest($this->request)->run()) {
            // Input was OK
        

        echo view('Login', ['validation' => $validation]); 

In my view I have:

Code:
<div><?php echo $validation->listErrors(); ?></div>
Reply


Messages In This Thread
validation - by aparedesv - 10-20-2019, 11:42 PM
RE: validation - by aparedesv - 10-21-2019, 02:59 AM
RE: validation - by InsiteFX - 10-21-2019, 03:11 AM
RE: validation - by EvilMoe - 10-29-2019, 11:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB