• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
validate form CI4

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

#2
Here's the User Guide page for that
Reply

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

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

#4
What message is the Exception saying?
Reply

#5
"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');
                }
                
    }
Reply

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

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

#7
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.
Reply

#8
it works fine.

@Lonnie You already did it (https://github.com/bcit-ci/CodeIgniter4/...40c1b7b97b)

@gra are you sure to use the latest version ?
Reply

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

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

use the develop branch.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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