Allow managed_file form elements to specify FILE_EXISTS_REPLACE behavior

Created on 8 November 2018, about 6 years ago
Updated 6 April 2023, over 1 year ago

The managed_file FormElement (Drupal\file\Element\ManagedFile) valueCallback implementation calls file_managed_file_save_upload($element, $form_state) which calls _file_save_upload_from_form($element, $form_state). The default value for $replace is FILE_EXISTS_RENAME. It would be nice if the element provided an attribute that allows us to specify what we want the behavior to be.

Suggestion: Add a new attribute to the element #file_exists_behavior, retrieve that value in valueCallback, modify file_managed_file_save_upload to accept the argument (with a default value of FILE_EXISTS_RENAME) and pass it along to _file_save_upload_from_form.

Feature request
Status

Needs work

Version

10.1

Component
File system 

Last updated about 11 hours ago

Created by

🇺🇸United States vegantriathlete Lakewood, CO

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.71.5 2024