file_managed FAPI field: TypeError: this.value is undefined

Created on 27 March 2017, about 7 years ago
Updated 26 June 2023, 12 months ago

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;
}
πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jacob.embree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024