[Update]
Upon further investigation it seems that the message isn't appearing due to the following javascript error:
"Uncaught TypeError: Cannot read property 'length' of undefined"
I'm not sure how to resolve this error, but the following issues may be related:
- [D7] Duplicate HTML IDs are created for file_managed_file fields
- Duplicate HTML IDs are created for file_managed_file fields
Description
I'm trying to create a custom form with some number of file upload fields (for now I'm using the hard-coded value 3).
I have added an #upload_validators attribute to the managed_file element that calls file_validate_extensions and passes in "doc" as the only valid filetype.
When I try to upload a .jpg, an error appears -- which is what I want. However, the error doesn't contain any text.
Any idea what I'm doing wrong?
Code
function mymodule_example1_form($form_state) {
$num_docs = 3;
// Build the number of name fieldsets indicated by $form_state['num_docs'].
for ($i = 1; $i <= $num_docs; $i++) {
$form['managed_file'][$i] = array(
'#type' => 'managed_file',
'#title' => 'Managed File' . $i,
'#progress_indicator' => 'throbber',
'#progress_message' => 'Upload successful!',
"#upload_validators" => array("file_validate_extensions" => array("doc")),
'#upload_location' => 'public://doc/',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}