Welcome Guest, Not a member yet? Register   Sign In
Codeigniter form validation in config depends on another input
#1

(This post was last modified: 05-11-2017, 07:25 AM by vahid.vdn.)

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:


Code:
'user' => array(
   array(
       'field' => 'user[phone]',
       'rules' => 'required'
   ),
   array(
       'field' => 'user[email]',
   ),
   array(
       '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?
Reply


Messages In This Thread
Codeigniter form validation in config depends on another input - by vahid.vdn - 05-11-2017, 07:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB