How to customize label on this codeigniter validation |
There are more than 200 similar checks in my project:
if($this->request->getMethod() == 'post' && $this->validate([ 'category' => 'required', 'title' => 'required|max_length[100]' ], [ 'title' => [ 'required' => 'No {field} provided' ] ])) I only need to change the label. I tried like this: if($this->request->getMethod() == 'post' && $this->validate([ 'category' => 'required', 'title' => 'required|max_length[100]' ], [ 'title' => [ 'label' => 'Title' ] ])) But it doesn't work! How to do this without rewriting a lot of code?
Try this:
PHP Code: if($this->request->getMethod() == 'post' && $this->validate([ And, if you want to add a custom message: PHP Code: if($this->request->getMethod() == 'post' && $this->validate([ 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
Please in the future use the Forums editor and the php tag for php code.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |