Hi
I've tried adding validation to a file upload box. This works brilliantly on the initial post creation but when I go back into the post to edit the content or title it throws a validation failure as the upload box is not filled out.
Here is the code for my metabox:
public function generateMetaBox($meta_boxes){
$prefix = 'downloads';
$prefix=str_replace(' ','_',$prefix);
// General
$meta_boxes[]=array(
'id'=>'general',
'title'=>'General Download Settings',
'post_types' => 'downloads',
'context' => 'normal',
'priority' => 'high',
'fields'=> array(
array(
'name' => 'File',
'id' => $prefix.'_file',
'type' => 'file',
'desc' => 'Select the file from your computer to upload.',
'max_file_uploads' => 1,
'upload_dir' => WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'downloads'
),
),
'validation' => array(
'rules' => array(
'_file_downloads_file[]' => array(
'required' => true,
),
),
)
);
return $meta_boxes;
}
Is there a work around for this?
Thanks!