Setting to 8.4.x because someone will anyway, but I don't know if this applies to Drupal 8.
Using the file_managed
element type with the form API, and using the #upload_validators
FAPI property with file_validate_extensions
, after selecting a file from the local file system for upload, the console emits
TypeError: this.value is undefined
.
validateExtension()
is being attached to the <div>
that contains the <input>
's. The div has no value attribue. I think file_managed_file_process()
is the function that sets Drupal.settings.file. The file behavior iterates over Drupal.settings.file.
To repoduce you can use this module and go to /admin/custom:
function hook_menu() {
$items['admin/custom'] = array(
"title" => "Blah",
"page callback" => "drupal_get_form",
"page arguments" => array("blah_form"),
);
return $items;
}
function blah_form($form, $form_state) {
$form['file'] = array(
'#type' => 'managed_file',
'#upload_validators' => array(
'file_validate_extensions' => array(
'xml'
),
),
);
return $form;
}
Comments
Comment #2
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedComment #13
smustgrave CreditAttribution: smustgrave at Mobomo commentedNot sure I understand the issue. Can you confirm this is still an issue in Drupal 9.5?
If so please update the issue summary with steps to reproduce.
Comment #16
smustgrave CreditAttribution: smustgrave at Mobomo commentedIf still a valid bug please reopen updating issue summary for D10 and up.
Thanks!