data-options doesn't override existing config

Created on 15 September 2025, 28 days ago

Problem/Motivation

The data-options introduced by 📌 Allow custom data-options to added to elements JavaScript options Active 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

🐛 Bug report
Status

Active

Version

6.3

Component

Code

Created by

🇧🇷Brazil hfernandes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

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