Metabox Version 4.8.7
I want File field required but the validation is only working of INPUT fields not for File Type or File Upload Field http://i.imgur.com/DP5Wbnq.png
$meta_boxes[] = array(
// Meta box id, UNIQUE per meta box. Optional since 4.1.5
'id' => 'standard',
// Meta box title - Will appear at the drag and drop handle bar. Required.
'title' => esc_html__( 'Standard Fields', 'your-prefix' ),
// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.
'post_types' => array( 'post', 'page' ),
// Where the meta box appear: normal (default), advanced, side. Optional.
'context' => 'normal',
// Order of meta box: high (default), low. Optional.
'priority' => 'high',
// Auto save: true, false (default). Optional.
'autosave' => true,
// List of meta fields
'fields' => array(
array(
'name' => esc_html__( 'Image', 'your-prefix' ),
'id' => "{$oyeprefix}file1",
'type' => 'file',
'max_file_uploads' => 1
),
),
'validation' => array(
'rules' => array(
"{$oyeprefix}file1" => array(
'required' => true,
),
),
// optional override of default jquery.validate messages
'messages' => array(
"{$oyeprefix}file1" => array(
'required' => esc_html__( 'File is required', 'your-prefix' ),
),
),
),
);