Support Forum
Hi,
I'm having troubles with the file extension validation in a frontend form. Here's the code with the only relevant field.
add_filter( 'rwmb_meta_boxes', 'nvf_register_mb_candidatura_form_input' );
function nvf_register_mb_candidatura_form_input( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Input Formulário', 'nvf-gb-front' ),
'id' => 'candidatura-form-details',
'post_types' => ['candidatura_bolsa'],
'fields' => [
[
'name' => __( 'Upload Requested Files', 'nvf-gb-front' ),
'id' => $prefix . 'uploaded_files',
'type' => 'file',
'max_file_uploads' => 20,
'force_delete' => true,
],
],
'validation' => [
'rules' => [
$prefix . 'uploaded_files' => [
'extension' => 'pdf',
],
],
'messages' => [
$prefix . 'uploaded_files' => [
'extension' => 'file extension not allowed',
],
],
],
];
return $meta_boxes;
}
Any clue on how to make it work?
I'm using MB AIO Version 1.14.3 and MB Version 5.4.6
Thanks in advance.