In order to fix #103680: Path alias validation should test for full URLs I want to add an URL element that allows developers to create text fields that accept absolute URLs, URL paths or URL aliases or a combination of these three.

What this patch should fix, directly or indirectly:
- Automatically removed leading and trailing slashes from URL paths and URL aliases (UX problem and bug).
- Centralised validation for different kinds of URLs, which makes code easier and fixes numerous bugs.
- One element that can accept different kind of URLs. It is possible with textfields, but that's not as clean.

For this menu_valid_path() needs to be split in a function that checks if a URL path is actually valid (like the name suggests) and a function that does an access check. Path_admin_form_validate() and path_form_element_validate() also need to be changed to provide one URL alias validation function. Both new validation functions should simply return a boolean.

This approach would fix numerous issues across Drupal. It does not really change the API, but it rather extends it.

CommentFileSizeAuthor
#3 624812-url-field.patch7.07 KBbleen

Comments

seutje’s picture

<font size="friggin huge">+</font> (a friggin huge +)

I think this would make a lot of lives way easier and result in a big reduction in killed kittens

bleen’s picture

Version: 7.x-dev » 8.x-dev
Category: bug » feature

As much as I like this idea ... I think it's a new feature and therefor -> D8

bleen’s picture

Component: forms system » field system
StatusFileSize
new7.07 KB

EDIT: Ignore this ... I meant this for a completely different issue

bleen’s picture

Component: field system » forms system
xano’s picture

Well, it would be great if we could add a URL form element and use that for the field widget instead of duplicating the functionality.

bleen’s picture

Isn't this issue covered by #1174630: Add new HTML5 FAPI element: url

Duplicate?

xano’s picture

Assigned: xano » Unassigned
Status: Active » Closed (duplicate)