diff --git a/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php b/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php index c759d6e7b2..6b4f08e913 100644 --- a/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php +++ b/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php @@ -131,7 +131,13 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $link_url = Url::fromUri(urldecode('base:' . $item->link_uri)); } else { - $link_url = $this->pathValidator->getUrlIfValid($item->link_uri ?? ''); + // Check if the link is an anchor within the current page. + if (str_starts_with($item->link_uri ?? '', "#")) { + $link_url = Url::fromUserInput($item->link_uri); + } + else { + $link_url = $this->pathValidator->getUrlIfValid($item->link_uri ?? ''); + } } $link_render_array = [ '#type' => 'link',