1

I am trying to set custom messages in CI3 for the form validation rules i have set. For this, i am using a config file:

$config = array(
        'register' => array(
                array(
                        'field' => 'username',
                        'label' => 'Username',
                        'rules' => 'trim|required|min_length[5]',
                        'errors'=> array(
                            'required'      => 'Trebuie introdus',
                            'min_length[5]' => 'Minim 5 caractere'
                        )
                ),
rest of arrays

The 'required' rule displays the message i have set.

The 'min_length[5]' displays the standard message. I can't figure out what i am missing :D I have also tried to pass the parameters and still the same.

'min_length[5]' => 'Minim %s caractere'

I don't want to override the global file.

1 Answer 1

1

You need to leave off the [5] behind min_length in the errors array to display the custom message:

$config = array(
        'register' => array(
                array(
                        'field' => 'username',
                        'label' => 'Username',
                        'rules' => 'trim|required|min_length[5]',
                        'errors'=> array(
                            'required'      => 'Trebuie introdus',
                            'min_length' => 'Minim 5 caractere'
                        )
                ),
rest of arrays
Sign up to request clarification or add additional context in comments.

1 Comment

HA, did not know that. Works. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.