Problem/Motivation

I have tried to upload an image file by managed_file. Also I have set allowed extensions for managed_file form field.
Form
Error message showing twice for invalid file format.
Form Error

Steps to reproduce the problem

Create a Form with below code for form elements.

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['image'] = [
      '#type' => 'managed_file',
      '#title' => $this->t('Image ( allowed file formats: gif png jpg jpeg )'),
      '#upload_location' => 'public://upload/image',
      '#default_value' => '',
      '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
      ),
    ];

    $form['submit'] = [
        '#type' => 'submit',
        '#value' => t('Submit'),
    ];

    return $form;
  }

Upload a PDF file in order to see the bug.

CommentFileSizeAuthor
form-error.png26.81 KBsyammohanmp
form.png13.1 KBsyammohanmp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

syammohan_zyxware created an issue. See original summary.

syammohanmp’s picture

Issue summary: View changes
cilefen’s picture

Title: Error message showing twice for invalid file format. » Validation message showing twice for invalid file format
Version: 8.2.x-dev » 8.3.x-dev
Priority: Critical » Major
Issue tags: -core, -form, -managed_file
Related issues: +#2346893: Duplicate AJAX wrapper around a file field

This doesn't come close to a critical issue. It looks to be a duplicate.

cilefen’s picture

Status: Active » Closed (duplicate)