I'm trying to get file type for (.vtt) file for file picker moodle form element.
$options = array('subdirs' => 0, 'maxbytes' => '', 'maxfiles' => 1, 'context' => $context, 'accepted_types' => array('text/vtt'), 'return_types'=> FILE_INTERNAL | FILE_EXTERNAL );
$mform->addElement('filepicker', 'attachment', get_string('attachment'), null, options);
The form was not restricting with Error code: invalidfiletype, if there is other than .vtt file uploaded.
File Type taken from : https://github.com/moodle/moodle/blob/master/lib/classes/filetypes.php