• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codelgniter 4 from validation

#1
Hello guys am stuck tying to learn this ci4 validations

this is my view code
PHP Code:
<?= form_open('main/get_post'?>

<h5>Username</h5>
<input type="text" name="username" value="<?= old('username'?>" size="50" />


<div><input type="submit" value="Submit" /></div>

<?= form_close(); ?>


here my controller
PHP Code:
public function get_post()
    {
        $validation =  \Config\Services::validation();

        $validation->setRules([
            'username' => ['label' => 'Username''rules' => 'required'],
            'password' => ['label' => 'Password''rules' => 'required|min_length[10]']
        ]);

        $errors $validation->getErrors();

        foreach($errors as $error)
        {
            echo $error;
        }
    


i really do no know how to check errors i follow d docs i can get it
onlike ci4 we use if($this->form_validation == false;

here i am deeply confuse.
Reply


Messages In This Thread
codelgniter 4 from validation - by seunex - 11-04-2019, 11:03 AM
RE: codelgniter 4 from validation - by mightyted - 11-04-2019, 12:59 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.