1

How to get array from form validation config file in controller?

application/config/form_validation.php

I have an idea to save my form validation array into config.php, and than to reference it in form_validation.php. Then I will be able to get it in controller, and be able to use it in validation.

Is there any better (direct) way?

1 Answer 1

6

Try

$this->config->load("form_validation");

Then

$this->config->item($key_name);

Docs:- http://ellislab.com/codeigniter/user_guide/libraries/config.html

Sign up to request clarification or add additional context in comments.

3 Comments

I am new to CodeIgniter world, so I was confused with $config[] variable. I thought that $config[] from config.php will overwrite $config[] from form_validation.php file when I do $this->config->load("form_validation"); . I am wrong, right? :)
The documentation has explain this :- Note: If you do create your own config files use the same format as the primary one, storing your items in an array called $config. CodeIgniter will intelligently manage these files so there will be no conflict even though the array has the same name (assuming an array index is not named the same as another).
its not working, this only return config item, not array from config>form_validation.php

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.