Problem/Motivation

The data-options introduced by #3493832: Allow custom data-options to be added to elements JavaScript options isn't working properly.
It allows adding new attributes, but not overriding existing ones.

Steps to reproduce

  1. Create a new webform and add a telephone field.
  2. In the field settings, activate the Enhance support for international phone numbers.
  3. Go to the Advanced tab and add the following to Element custom attributes (YAML):
    data-options:
      hiddenInput: '{"nationalMode": "true"}'
    

By default, the nationalMode is false and adding this data-options doesn't override the settings.

Proposed resolution

Instead of options = $.extend(JSON.parse($telephone.attr('data-options')), options); change it to:
options = $.extend(true, options, JSON.parse($telephone.attr('data-options')));
It will also allow the two objects to be merged.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork webform-3546716

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

hfernandes created an issue. See original summary.

jrockowitz’s picture

That seems reasonable. Please create an MR.

hfernandes’s picture

Assigned: hfernandes » Unassigned
Status: Active » Needs review

MR created for review.

jrockowitz’s picture

Status: Needs review » Fixed

Looks good. Failing test is unrelated

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

hfernandes’s picture

Thanks for the quick turnaround.

Status: Fixed » Closed (fixed)

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