|
我把我的各个表单提交验证规则写在了application/config/form_validation.php,但是发现各个Sets的规则有很多类似,比如管理人姓名和客户姓名其实判断是一样的,但是各个Sets又有组合的不同,比如这个表单是姓名和电话,那个表单是姓名和地址。有没有更灵活的写法,可以不必再规则里复制来复制去?PHP复制代码 $config = array(
'signup' => array(
array(
'field' => 'username',
'label' => 'Username',
'rules' => 'required'
),
array(
'field' => 'password',
'label' => 'Password',
'rules' => 'required'
),
array(
'field' => 'passconf',
'label' => 'PasswordConfirmation',
'rules' => 'required'
),
array(
'field' => 'email',
'label' => 'Email',
'rules' => 'required'
)
),
'email' => array(
array(
'field' => 'email',
'label' => 'Email',
'rules' => 'required'
)
array(
'field' => 'name',
'label' => 'Name',
'rules' => 'required|alpha'
),
array(
'field' => 'title',
'label' => 'Title',
'rules' => 'required'
),
array(
'field' => 'message',
'label' => 'MessageBody',
'rules' => 'required'
)
)
); 复制代码 |
|