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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3252605-6.patch | 1.08 KB | jrockowitz |
| #5 | 3252605-5.patch | 1.03 KB | jrockowitz |
| #3 | 3252605-3-allow_default_format_on_managedfile_types.patch | 2.96 KB | pvbergen |
Issue fork webform-3252605
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
Comment #2
pvbergen commentedComment #3
pvbergen commentedUpdating patch due to some rogue return statement in #2.
Comment #4
pvbergen commentedComment #5
jrockowitz commentedThis 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.
Comment #6
jrockowitz commentedHere is a slightly better solution.
Comment #7
jrockowitz commentedComment #9
jrockowitz commentedThis is going to need a little test coverage, especially if at some point we improve the solution/approach.
Comment #10
jrockowitz commentedComment #14
jrockowitz commented