Welcome Guest, Not a member yet? Register   Sign In
How to customize label on this codeigniter validation
#2

(This post was last modified: 04-12-2023, 01:39 PM by digitalarts.)

Try this:

PHP Code:
if($this->request->getMethod() == 'post' && $this->validate([
     'category' => 'required',
     'title' => [
          'label' => 'Title',
          'rules' => 'required|max_length[100]',
      ],
])) 

And, if you want to add a custom message:

PHP Code:
if($this->request->getMethod() == 'post' && $this->validate([
     'category' => 'required',
     'title' => [
          'label' => 'Title',
          'rules' => 'required|max_length[100]',
          'errors' => [
              'max_length' => 'The {field} field cannot be more than 100 characters long.',
          ],
      ],
])) 

That said, if you have more than 200 validation rules, you should probably store them in a variable in the Validation configuration file.

https://codeigniter.com/user_guide/libra...ation.html
Reply


Messages In This Thread
RE: How to customize label on this codeigniter validation - by digitalarts - 04-12-2023, 01:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB