Skip to content

fix issue #27: serialize the widget form the way a browser would - #28

Open
lucafuser wants to merge 1 commit into
mage-os:masterfrom
lucafuser:fix/widget-form-duplicate-field-names
Open

lucafuser wants to merge 1 commit into
mage-os:masterfrom
lucafuser:fix/widget-form-duplicate-field-names

Conversation

@lucafuser

Copy link
Copy Markdown

Two blocks can render the same widget parameter. Magento\Widget\Block\Adminhtml\Widget\Options emits every parameter, including the ones declared visible="false", as a field carrying the widget.xml default; a module adding its own options block to the adminhtml_widget_loadoptions handle then renders some of those parameters again as visible fields under the same name. Prototype's accumulator concatenated duplicates, so parameters[loop] arrived as ['0','1']: selects were forced to their first allowed option and text parameters were imploded or dropped.

It now follows the submit semantics of a form: a trailing [] makes a value a list, everything else is last one wins, unchecked checkboxes and radios are skipped rather than contributing their value attribute, and disabled, file, submit and button fields are left out. Reading the element directly instead of looking it up by id also stops fields without an id from being dropped.

Closes #27

Two blocks can render the same widget parameter. Magento\Widget\Block\Adminhtml\Widget\Options emits
every parameter, including the ones declared visible="false", as a field carrying the widget.xml
default; a module adding its own options block to the adminhtml_widget_loadoptions handle then renders
some of those parameters again as visible fields under the same name. Prototype's accumulator
concatenated duplicates, so parameters[loop] arrived as ['0','1']: selects were forced to their first
allowed option and text parameters were imploded or dropped.

It now follows the submit semantics of a form: a trailing [] makes a value a list, everything else is
last one wins, unchecked checkboxes and radios are skipped rather than contributing their value
attribute, and disabled, file, submit and button fields are left out. Reading the element directly
instead of looking it up by id also stops fields without an id from being dropped.
@lucafuser
lucafuser requested review from a team and dadolun95 as code owners August 31, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget parameters rendered twice are submitted as a list of both values, and the widget is saved with the wrong one

1 participant