Welcome Guest, Not a member yet? Register   Sign In
Disable error message on a single rule in form validation
#1

I want to disable the error message for one rule in form validation. How to do that?

On the following example, if the email is provided but not valid, it should displays a message. 
If the email is not provided, I don't want a message to be displayed. 

Quote:$validation->setRules([
            'email' => [
                'label'  => 'email',
                'rules'  => 'trim|required|valid_email',
                'errors' => [  'valid_email' => 'You must provide a valid email address.',
                                'required' => "I don't want a message here !!!"]
            ]
        ]);

if (!$validation->run())
 {

    //...


I read the following note on this page : https://codeigniter4.github.io/userguide...r-messages
Quote:If you pass the last parameter the labeled style error messages will be ignored.

But it's not clear for me.
Reply


Messages In This Thread
Disable error message on a single rule in form validation - by imabot - 05-10-2020, 08:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB