• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please for God Sake help me with Form Validation

I have been trying to learn CI4 i always stuck in form validation. 

When i try to echo out the validation it shows blank

PHP Code:
//* Create project
    public function create_project()
        $validation = \Config\Services::validation();

        //* Setting validation rules

        $validation->setRule('project_name''Project Name''required');

        if(! $this->validate([]))
            if ($validation->hasError('project_name'))
                echo $validation->getError('project_name');
            echo "validation is good";

Please help me learn this new challenge please

The way I do it is the following:
PHP Code:
if ($this->request->getMethod() == 'post' && !$validation->withRequest($this->request)->run()) {
//display errors(with view)
//display view 

I believe you're passing no validation rules when you use $this->validate([]).
Simpler is always better

Thanks but I will like to get my own custorm error set

In CI3 we did if($this->form_validstion-.run() == false)

We use run to run the validation and use validarion_erros to get it.

I need better way to validate pls

See my post in your other topic for this.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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