Validation rules to a config file in CodeIgniter

You can save sets of rules to a config file. To start, create a new file called form_validation.php, inside the application/config/ directory. The rules must be contained within a variable $config, as with all other config files.
The rules from our Signu form would now appear as follows:

Creating sets of rules
If you have more than one form that needs validating, you can create sets of rules. To do this, you need to place the rules into ‘sub-arrays’. The rules for our contact form would appear as follows when we place it into a set:

This method allows you to have as many sets of rules as you need.

Calling a specific set of rules
You need to specify the rule set that you want to validate the form against, on the run function. Our edited controller would now look like this:

View Demo

Validation rules to a config file in CodeIgniter (Download script)
Size: V 1
Version: 2.61 MB

Anuj Kumar

I'm Anuj kumar a web developer with 4+ year experience .I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to is provide php , jquery , mysql , phpoops and other web development tutorials. I am trying best effort to make PHPGurukul useful for every single moment spend on this website. If you think this website is useful to visit please share with your friend and buddies.

Recommended Tutorials for you

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *