Welcome Guest, Not a member yet? Register   Sign In
form_validation matches[] multidimensional array bug fix :)
#1

[eluser]itsme[/eluser]
I found that the current matches method in form_validation library does not support fields with multidimensional
array as a name so i edited the method to support it, i hope it will help you in the future Smile

The new method is :-

Code:
public function matches($str, $field)
{
  if(strpos($field,"]"))
  {
   list($arr_name,$field_name)=explode("[",$field);
  
   $field_name=substr($field_name,0,-1);
  
   if ( ! isset($_POST[$arr_name][$field_name]))
   {
    return FALSE;
   }
  
   $field = $_POST[$arr_name][$field_name];
  
  
  }
  else {
   if ( ! isset($_POST[$field]))
   {
    return FALSE;
   }

   $field = $_POST[$field];
  }
  
  
  return ($str !== $field) ? FALSE : TRUE;
}

#2

[eluser]Phil Sturgeon[/eluser]
When you find a bug can you please report it on GitHub, or send a pull request?

Also, please use code tags when you post code to the forums, it's tough to read otherwise.
#3

[eluser]itsme[/eluser]
thanks Phil Sturgeon , i edited my post and write the issue on GitHub bug tracker




Theme © iAndrew 2016 - Forum software by © MyBB