I am working with files in a Drupal module. I added this form:
$form['Background_image'] = [ '#type' => 'managed_file', '#title' => t('Image'), '#progress_message' => t('Please wait...'), '#progress_indicator' => 'bar', '#description' => t('Click "Browse..." to select an image to upload.'), '#required' => TRUE, '#upload_validators' => ['file_validate_extensions' => ['jpeg jpg png gif']], '#upload_location' => 'public://backgroundimage/', '#default_value' => $this->options['Background_image'], ];
The file is added properly. Once the file is uploaded a remove button appears allowing to remove the file and upload a new one. The problem is that this button is not working. How can I remove an uploaded file?