? ? Pending

User tests: Successful: Unsuccessful:

avatar PhocaCz
PhocaCz
27 Sep 2022

According to this documentation: https://docs.joomla.org/Tel_form_field_type is "tel" form field an alias for "text", but it does not contain "pattern" attribute. This means, XML form field types "tel" will not include pattern attribute when rendering.

BEFORE PR

  • XML form field type="tel" does not render "pattern" attribute

AFTER PR

  • XML form field type="tel" will render the "pattern" attribute the same way like XML form field type="text"

Example:

<field name="phone_1" type="tel" label="COM_XXX_PHONE_1_LABEL" description="COM_XXX_PHONE_1_DESC" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" validate="tel" class=" validate-tel" />

will produce

BEFORE PR:

<input type="tel" inputmode="tel" name="jform[phone_1]" class="form-control validate-tel" id="jform_phone_1" value="" aria-describedby="jform_phone_1-desc">

AFTER PR:

<input type="tel" inputmode="tel" name="jform[phone_1]" class="form-control validate-tel" id="jform_phone_1" value="" aria-describedby="jform_phone_1-desc" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}">

Summary of Changes

Adding option to add "pattern" attribute into the "tel" form field like it is included in "text" form field

Testing Instructions

Edit the file, create form field with tel type and pattern. Such field will include pattern attribute when rendering.

Actual result BEFORE applying this Pull Request

Pattern attribute is not rendered in "tel" form fields

Expected result AFTER applying this Pull Request

Pattern attribute is rendered in "tel" form fields

avatar PhocaCz PhocaCz - open - 27 Sep 2022
avatar PhocaCz PhocaCz - change - 27 Sep 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Sep 2022
Category Layout
avatar PhocaCz PhocaCz - change - 27 Sep 2022
The description was changed
avatar PhocaCz PhocaCz - edited - 27 Sep 2022
avatar PhocaCz PhocaCz - change - 27 Sep 2022
The description was changed
avatar PhocaCz PhocaCz - edited - 27 Sep 2022
avatar PhocaCz PhocaCz - change - 27 Sep 2022
The description was changed
avatar PhocaCz PhocaCz - edited - 27 Sep 2022
avatar brianteeman
brianteeman - comment - 27 Sep 2022

The tel format is useless and really should have been removed but b/c prevented it.

There is no global standard for a telephone number pattern. Far too often on sites that does use this input type and a pattern I end up putting my number in completely the wrong places just to satisfy a pattern that does not apply to my number.

avatar HLeithner
HLeithner - comment - 27 Sep 2022

Google has a phone number pattern library. Not sure if it make sense for US but at least it's the correct one.

In the end phone numbers are saved by domain providers with +43,15346454.

I would suggest not to validate any fix pattern luk suggested.

I talk about this lib https://github.com/google/libphonenumber

avatar PhocaCz
PhocaCz - comment - 27 Sep 2022

Hi, I personally agree with you, but this PR is not about what the recommendation is - to use or not to use the "tel" form field, but to add the missing option.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel

HTML Input type tel form field includes the attribute option "pattern" which is not rendered by Joomla Form library even it is set in XML.

Even if we can think anything about the tel type, the missing option to add the pattern attribute is essential for this type.

avatar n3t
n3t - comment - 28 Sep 2022

I have tested this item successfully on a4a6acb

Works as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38852.

avatar n3t n3t - test_item - 28 Sep 2022 - Tested successfully
avatar Fedik
Fedik - comment - 28 Sep 2022

I have tested this item successfully on a4a6acb


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38852.

avatar Fedik Fedik - test_item - 28 Sep 2022 - Tested successfully
avatar Fedik
Fedik - comment - 28 Sep 2022

patern is valid attribute for the input.

avatar Fedik Fedik - change - 28 Sep 2022
Status Pending Ready to Commit
avatar Fedik
Fedik - comment - 28 Sep 2022

r2c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38852.

avatar laoneo laoneo - change - 5 Oct 2022
Labels Added: ? ?
avatar laoneo
laoneo - comment - 5 Oct 2022

Just to be sure about this change. When an extension had a form with a pattern attribute on a tel field, then it didn't comply before this change but does now after it? Even when it is a bugfix, I would rebase this to 5.0 as it adds a new behavior.

avatar Fedik
Fedik - comment - 5 Oct 2022

Yes, the attribute was ignored before.
The PR is fixing that, I do not see a reason to wait for 5, it a simple bug fix

avatar HLeithner HLeithner - change - 15 Oct 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-10-15 09:24:21
Closed_By HLeithner
avatar HLeithner HLeithner - close - 15 Oct 2022
avatar HLeithner HLeithner - merge - 15 Oct 2022
avatar HLeithner
HLeithner - comment - 15 Oct 2022

Maintainers decided not to add this to a bugfix release because it's a kind of a new feature. I rebased it to 4.3-dev and merged it.
Thanks @PhocaCz for fixing this

avatar obuisard
obuisard - comment - 15 Oct 2022

Thank you Jan @PhocaCz for this contribution

avatar obuisard
obuisard - comment - 15 Oct 2022

The documentation needs to be updated

Add a Comment

Login with GitHub to post a comment