Welcome Guest, Not a member yet? Register   Sign In
Help me with form validation class
#1

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";
        }
    
Reply
#2

(This post was last modified: 02-24-2020, 08:48 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

No helpful i need to setRules
Reply
#4

He is setting the rules in the model also take a look at the models.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB