Cms: Mailto links should be allowed in URL fields

Created on 24 Jan 2020  Â·  7Comments  Â·  Source: craftcms/cms

Description

mailto:[email protected] is a valid URL for <input type="url">, but they fail the validation in craft\validators\UrlValidator.

Steps to reproduce

  1. Add a URL field to a section
  2. Enter mailto:[email protected] in the field and save.
  3. See the error message [fieldname] is not a valid URL.

Additional info

  • Craft version: Craft Pro 3.3.20.1
  • PHP version: 7.1.32
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions:
Asset Rev 6.0.2
Azure Blob Remote Volume 1.0.2
Calendar 2.0.25
Navigation 1.2.7
Redactor 2.4.0
Redirect plugin for Craft 3 1.0.23
Super Table 2.3.3
Video Embed 1.2.1
VZ Address 2.0.2
Width Fieldtype 1.0.6
content modeling enhancement

Most helpful comment

This is resolved for the next 3.6 release ✨

URL fields now have an “Allowed URL Types” setting, with “Web page”, “Telephone”, and “Email” options:

The new “Allowed URL Types” setting

When 2+ options are checked, a dropdown will be displayed to the left of the URL input, which lists the options you’ve selected.

A URL field with the “Email” input type selected

Phone numbers will get a tel: prefix added; emails will get a mailto: prefix. But those will be hidden from the actual UI.

All 7 comments

This still appears to be an issue in Pro 3.5.14

Just giving this a bump as I had to switch a field from a URL field to a Plain Text field today so that users could use mailto: links.

Giving this a bump as well; I find I _frequently_ need to use Plain Text fields instead of url fields because of this issue.

This is resolved for the next 3.6 release ✨

URL fields now have an “Allowed URL Types” setting, with “Web page”, “Telephone”, and “Email” options:

The new “Allowed URL Types” setting

When 2+ options are checked, a dropdown will be displayed to the left of the URL input, which lists the options you’ve selected.

A URL field with the “Email” input type selected

Phone numbers will get a tel: prefix added; emails will get a mailto: prefix. But those will be hidden from the actual UI.

Craft 3.6 has now been officially released ✨

Awesome! Any chance we could also get this ability when the URL field is within a Table field? Thanks

@melissadoyon Just created a new issue for that: #7512

Was this page helpful?
0 / 5 - 0 ratings