0

I am using drupal 8.4.2. I have created my content type and I have an image field in the form fields.

The image upload field is showing on the page but, the upload button is not showing. If I inspect the element, I can see that 'js-hide' class is added for the upload button. I think that is coming from the processManagedFile function in core/modules/file/src/Element/ManagedFile.php file

$element['upload_button'] = [
      '#name' => $parents_prefix . '_upload_button',
      '#type' => 'submit',
      '#value' => t('Upload'),
      '#attributes' => ['class' => ['js-hide']], //hide class added from here
      '#validate' => [],
      '#submit' => ['file_managed_file_submit'],
      '#limit_validation_errors' => [$element['#parents']],
      '#ajax' => $ajax_settings,
      '#weight' => -5,
    ];

It means upload button is hidden in Drupal 8 by default.?

If so, after selecting an image, the upload should happen automatically. That is also not happening?

What might be the problem? Is there any setting I need to enable? I would like to have either upload button or the image should be uploaded automatically after selecting an image.

Note: I am having this form for admin. So any changes have to be done in theme, I should do that in seven theme.

siddiq
  • 1,693
  • 3
  • 17
  • 44
  • This is the intended behavior, by default the file is not supposed to be uploaded until content is saved, you have either a file input with "Choose file" text, or a "remove" button to be able to remove and switch the actual image file. – EricLavault Oct 15 '19 at 17:02
  • You are correct. But ajax upload should happen automatically which doesn't happen. I checked in the debug console, but no ajax request sent when uploading the image. Is there any configuration need to be set to enable ajax upload? – siddiq Oct 15 '19 at 22:39

0 Answers0