I have a link field and a boolean field. The link field will be displayed when the checkbox is ticked. However, the validation of the URL field stopped from working. The URL validation is working OK with no conditional rule.

I'm expecting to see the Manually entered paths should start with one of the following characters: / ? # error message when submitting the node. Without the validation, the front-end gets InvalidArgumentException: The internal path component 'www.google.com' is invalid. Its path component must have a leading slash, e.g. internal:/foo. in Drupal\Core\Url::fromInternalUri() (line 413 of core/lib/Drupal/Core/Url.php). error.

Steps to reproduce:

1. Manage dependencies.
2. Add link field in target field.
3. Add boolean field in controlled by.
4. The dependency would be the target field is visible when the control field is checked.
5. Edit or add a new node.
6. Tick checkbox.
7. Enter an URL that starts with "www" (eg. www.google.com) in the link field.
8. Save.
9. Check the node page.

CommentFileSizeAuthor
#6 after-patch.png74.8 KBlarisse
#6 before-patch.png271.91 KBlarisse
#2 3207751_2.patch479 byteslarisse

Comments

madelyncruz created an issue. See original summary.

larisse’s picture

StatusFileSize
new479 bytes

Hi! I think this patch will solve the problem!

larisse’s picture

Status: Active » Needs review
paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Patch #2 looks good to me.

colan’s picture

Version: 8.x-1.0-alpha10 » 4.x-dev
Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Is this still a problem in 4.x?

larisse’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community
StatusFileSize
new271.91 KB
new74.8 KB

Hi!

This still a problem in 4.x version. I have installed and test and URL validation link field still break the site, like you can see in image below. It's works after apply the patch.

colan’s picture

I just requeued #2 for testing.

kris77’s picture

Patch in #2 works for me in 4.x dev.

Thank you so much @larisse

madelyncruz’s picture

The patch works for me too. Thank you larisse!

thalles’s picture

Thanks everyone!

  • larisse authored e150739 on 4.x
    Issue #3207751 by larisse: URL validation of link field doesn't work
    
thalles’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alexandru.dumitru’s picture

This patch will trigger all errors, regardless if field if visible/hidden via conditional fields.
For example, apply the patch and hide a required field with conditional fields. Error will be triggered for the required field.

jonloh’s picture

I can confirm this patch triggered all errors regardless if the field is visible/hidden, as mentioned in #14.

Another issue is open to discuss this further: https://www.drupal.org/project/conditional_fields/issues/3344587

dqd’s picture

Status: Closed (fixed) » Needs work

This "dirty fix" in here committed caused many trouble including #3344587: Support for field hidden by condition losing its required status So I reopen this issue to discuss a better solution.

heddn’s picture

Is the dirty fix sufficient for us to mark a beta though?