CodeIgniter Forums
Help me with form validation class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Help me with form validation class (/showthread.php?tid=75583)



Help me with form validation class - seunex - 02-24-2020

Please correct this code why is it return false when the form feld are blank and i set it the required rule.

please help with this code corrected

PHP Code:
public function create_project()
    {
        $validation = \Config\Services::validation();

        //* Setting validation rules
        $validation->setRules([
            'project_name' => ['label' => 'Project Name''rules' => 'required'],
            'description' => ['label' => 'Comments''rules' => 'required']
        ]);

        if($validation->getErrors())
        {
            echo "We have errors";
        }
        else
        {
            echo "No errors";
        }
    



RE: Help me with form validation class - InsiteFX - 02-24-2020

I found the best way to learn the form validation is to look at the Myth/Auth Controller.

Myth::Auth

Also look at the login view for how he is displaying messages.


RE: Help me with form validation class - seunex - 02-29-2020

No helpful i need to setRules


RE: Help me with form validation class - InsiteFX - 03-01-2020

He is setting the rules in the model also take a look at the models.


RE: Help me with form validation class - seunex - 03-01-2020

After he set the rules how did he validate his method is diffrent if u now the login you can help me correct my codes in controller i will be gratefull this is the only section am having problem in ci4