• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter form validation in config depends on another input

I'm using Codeigniter form validation by config (not setting rules manually). What I need, is setting required rule depending on the other field. For example, Imagine we have the following rules:

'user' => array(
       'field' => 'user[phone]',
       'rules' => 'required'
       'field' => 'user[email]',
       'field' => 'user[foo]',
       //'rules' => 'required'

foo input must be required based on email field.
Note: It can be done with callback or anonymous function, but it makes it a bit difficult in big applications. Any idea?

Extend Form_validation with your own MY_Form_validation

You can then place your own rule methods in this file and set the rule as you would set any other rule.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.