Problem/Motivation

ManagedFile based element types (audio, document, image and video) don't respect the default format set in admin/structure/webform/config/elements.

Steps to reproduce

- Change the default format of audio, document, image or video field at admin/structure/webform/config/elements.
- Create a webform and add an element of the configured type
- Check the selected format under advanced. It will still show the standard format.

Proposed resolution

Apply the attached patch.
It does 3 things:
- It changes WebformManagedFileBase::getItemDefaultFormat to return the configured format.
- It changes WebformImageFile::getItemDefaultFormat to return the configured format or its standard format.
- It adds WebformElementInterface::hasItemFormat, a default implementation in WebformElementBase::hasItemFormat and a specialized implementation in WebformImageFile::hasItemFormat. This function allows to check a configured format for availability.

Remaining tasks

- Review of patch
- Possibly test for hasItemFormat.

User interface changes

- No changes to user interface.

API changes

- Additional method WebformElementInterface::hasItemFormat

Data model changes

- No data model changes

Issue fork webform-3252605

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pvbergen created an issue. See original summary.

pvbergen’s picture

pvbergen’s picture

StatusFileSize
new2.96 KB

Updating patch due to some rogue return statement in #2.

pvbergen’s picture

Title: File based field don't respect default format settings » File based fields don't respect default format settings
jrockowitz’s picture

StatusFileSize
new1.03 KB

This is a global issue for all elements.

The overridden format is not reflected in the element edit form.

The attached patch is an experiment in a more universal solution.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Here is a slightly better solution.

jrockowitz’s picture

Title: File based fields don't respect default format settings » Webform element edit form don't respect an element's default format settings

jrockowitz’s picture

Status: Needs review » Needs work

This is going to need a little test coverage, especially if at some point we improve the solution/approach.

jrockowitz’s picture

Status: Needs work » Needs review

The last submitted patch, 3: 3252605-3-allow_default_format_on_managedfile_types.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

The last submitted patch, 5: 3252605-5.patch, failed testing. View results

  • jrockowitz committed f25eae0 on 6.1.x
    Issue #3252605 by jrockowitz, pvbergen: Webform element edit form don't...
jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz committed f25eae0 on 6.x
    Issue #3252605 by jrockowitz, pvbergen: Webform element edit form don't...

  • jrockowitz committed f25eae0 on 6.2.x
    Issue #3252605 by jrockowitz, pvbergen: Webform element edit form don't...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.