CodeIgniter Forums
validate form CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: validate form CI4 (/thread-70410.html)

Pages: 1 2


validate form CI4 - gra - 04-05-2018

in ci3 $this->load->library('form_validation');
in ci4??


RE: validate form CI4 - kilishan - 04-05-2018

Here's the User Guide page for that


RE: validate form CI4 - gra - 04-06-2018

helper(['form', 'url']);

               if (! $this->validate([]))
               {
                       echo view('Signup', [
                               'validation' => $this->validation
                       ]);
               }
               else
               {
                       echo view('Success');
               }
 
is a exceptionHandler


RE: validate form CI4 - kilishan - 04-06-2018

What message is the Exception saying?


RE: validate form CI4 - gra - 04-07-2018

"Argument 1 passed to helper() must be of the type string, array given, called in C:\xampp\htdocs\ci4m_framework\application\Controllers\Login.php on line 10"
line 10 -> helper(['form', 'url']);
my source:
    public function index()
    {
        //echo view('w_login');
                $validation =  \Config\Services::validation();
                helper(['form', 'url']);
                //library(['validation']);
                
//                
//                
//                
//                
//                
//                
//                $validation->setRules([
//    'id' => 'required',
//    'pw' => 'required|min_length[10]'
//]);
//                
                if (! $this->validate([]))
                {
                        echo view('w_login', [
                                'validation' => $this->validation
                        ]);
                }
                else
                {
                        echo view('w_login');
                }
                
    }


RE: validate form CI4 - gra - 04-08-2018

modified helper(['form', 'url']); in helper('form', 'url');

in line if (! $this->validate([]))
exception
"Call to undefined method Login::validate()"


RE: validate form CI4 - kilishan - 04-08-2018

Quote:"Argument 1 passed to helper() must be of the type string, array given, called in C:\xampp\htdocs\ci4m_framework\application\Controllers\Login.php on line 10"

It tells you exactly what the error is there. The `helper()` method doesn't currently allow more than one helper to be loaded at a time. Hence, it requires a string, not an array. It probably should, and I'll make an issue to that affect to remind me, but doesn't currently. In your case, it's not biggie - the url helper is loaded by default.


RE: validate form CI4 - gabpnr - 04-08-2018

it works fine.

@Lonnie You already did it (https://github.com/bcit-ci/CodeIgniter4/commit/dae1cf8cd5f173af6b51d52a6241ea8a4bd4eeef#diff-9395cda73a10792d653d5540c1b7b97b)

@gra are you sure to use the latest version ?


RE: validate form CI4 - gra - 04-08-2018

used : https://github.com/bcit-ci/CodeIgniter4.git -> master


RE: validate form CI4 - gabpnr - 04-09-2018

ok, no commit on this branch since 24 Jun 2016 and helper() accept arrays since 20 Sep 2016

use the develop branch.