[eluser]palaniappanc[/eluser]
I'm getting an unexpected error (array to string conversion in validation.php on line 709).
Line 709: return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data));
I'm trying to validate a form. Part of it contains a variable number of text fields, and so I've used name="printfilenames[]" to get every input as an array. If I submit the form without any data at all, I get the following as my $_POST array (job_id is a hidden input that is automatically populated).
array
'job_id' => string '22' (length=2)
'printfilenames' =>
array
0 => string '' (length=0)
'filesavedto' => string '' (length=0)
'instructions' => string '' (length=0)
'jhb' => string '' (length=0)
'pjhb' => string '' (length=0)
These are my validation rules:
Code:
$rules['printfilenames']="callback_printfilenames_check|required";
$rules['filesavedto']="trim|required|xss_clean";
$rules['instructions']="trim|required|xss_clean";
$rules['jhb']="callback_jhb_check|required";
$this->validation->set_rules($rules);
The only one that is an array is printfilenames
Here is the printfilenames check function
Code:
function printfilenames_check($printfilenames)
{
$errors=0;
foreach($printfilenames as $it=>$printfilename)
{
if(trim($printfilename)=='')
{
$errors++;
}
}
$this->validation->set_message('filenames_check', 'All Print Filenames are required');
global $printfilenamesJson;
$printfilenamesJson=json_encode($printfilenames);
if($errors>0)
{
return FALSE;
}
else
{
return TRUE;
}
}
The error comes (obviously) after calling $this->validation->run()
I checked the validation.php file, which seems to take care of looking at arrays if present. Why is this error being generated? Any ideas on what I can do?
Thanks!