public function _validation_upload_ok($form_value, $form_field)
{
// Get files uploaded with errors
$upload_errors = Upload::get_errors();
// Check if this form field had an upload error
foreach ($upload_errors as $error)
{
if ($error['field'] == $form_field)
{
$this->set_message('upload_ok', $error['message'] . ' (' . $error['name'] . ').');
return false;
}
}
return true;
}
I understand now what you're trying to do here, and if called correctly, that should work. Do I understand you correctly in that if one of the uploads failed, you'll get the same error message with all your file upload form fields?
How do you call this method? Normal validation only runs on fields in $_POST, and file upload form fields are not in there.
public static function set_form_fields_example(Fieldset $form, $example_id = null)
{
if ($example_id != null)
{
$examples = self::get_example_info($example_id);
}
// File upload - set up several fields
for ($i = 1; $i <= Model_Mexamples::N_FILES; $i++)
{
$field = 'file_' . $i;
$field_id = 'file-' . $i;
$form->add($field,
"Upload File $i",
array(
'type' => 'file',
'size' => 50,
'id' => $field_id,
),
array(
array('upload_ok', "$field"),
)
);
}
"Polar A3"It looks like you're new here. If you want to get involved, click one of these buttons!