• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter form validation callbacks

#1
[eluser]Monarobase[/eluser]
Hello, using the form validation helper I have run into a limitation and would like to know if there is a clean way to do this or not.

In my form I've got an element called "name" which is a drop down list with "Yes", "No", "Other" and a text input called name_other and I want to specify that if "name_other" is selected in the drop down list then the name_other text field is required and otherwise is not.

I could do this using a callback but 15 fields like this would mean 15 callbacks unless I could retreive the field name in the callback in which case I could check "name_other" with a function like this :

Code:
function _check_other($val,$input_name)
{
   if($val == 'other') {
      if($_POST[$input_name.'_other'] == '') {
      
      }  
   }
}

Can I do something like this ? And if not would in not be an interesting feature to be able to have an extra $input_name value passed onto the callback function ?


Messages In This Thread
Codeigniter form validation callbacks - by El Forum - 01-18-2010, 08:32 AM
Codeigniter form validation callbacks - by El Forum - 01-18-2010, 09:11 AM
Codeigniter form validation callbacks - by El Forum - 01-18-2010, 09:28 AM
Codeigniter form validation callbacks - by El Forum - 01-18-2010, 02:16 PM
Codeigniter form validation callbacks - by El Forum - 01-18-2010, 02:36 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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