Add 'Required' Attribute Support to PhoneInternationalElement

Created on 31 January 2024, 11 months ago
Updated 29 May 2024, 7 months ago

Problem/Motivation

Currently, the PhoneInternationalElement custom form element does not support the addition of the required HTML attribute when the element is set as required. This is problematic for forms that need to enforce the completion of the phone number field, as there's no HTML5 validation for required fields.

Steps to reproduce

Create a form using the PhoneInternationalElement.
Set the #required attribute to TRUE on this element.
Render the form and inspect the HTML output.
Notice the absence of the required attribute in the rendered HTML.

Proposed resolution

Enhance the processInternationalPhone method within the PhoneInternationalElement class to conditionally add the required attribute to the element's attributes array based on the #required property.

User interface changes

This change will add the required attribute to the HTML output of the phone field when necessary, which may trigger HTML5 validation UI elements in browsers.

🐛 Bug report
Status

Fixed

Version

3.3

Component

Code

Created by

🇹🇳Tunisia matio89 UTC+1 🇹🇳

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024