From 45f33d2d70a1a24acd2c6cd55aa395f76bb93b31 Mon Sep 17 00:00:00 2001 From: Fedik Date: Mon, 9 Oct 2023 12:29:21 +0300 Subject: [PATCH] Check if the value consist with id:alias, extract the id only --- .../components/com_content/src/Field/Modal/ArticleField.php | 6 ++++++ .../components/com_menus/src/Field/Modal/MenuField.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/administrator/components/com_content/src/Field/Modal/ArticleField.php b/administrator/components/com_content/src/Field/Modal/ArticleField.php index e5d5e70b613f8..c173321bbf6c0 100644 --- a/administrator/components/com_content/src/Field/Modal/ArticleField.php +++ b/administrator/components/com_content/src/Field/Modal/ArticleField.php @@ -52,6 +52,12 @@ class ArticleField extends ModalSelectField */ public function setup(\SimpleXMLElement $element, $value, $group = null) { + // Check if the value consist with id:alias, extract the id only + if ($value && str_contains($value, ':')) { + [$id] = explode(':', $value, 2); + $value = (int) $id; + } + $result = parent::setup($element, $value, $group); if (!$result) { diff --git a/administrator/components/com_menus/src/Field/Modal/MenuField.php b/administrator/components/com_menus/src/Field/Modal/MenuField.php index f59726f5c5970..d383bbf90727e 100644 --- a/administrator/components/com_menus/src/Field/Modal/MenuField.php +++ b/administrator/components/com_menus/src/Field/Modal/MenuField.php @@ -145,6 +145,12 @@ public function __set($name, $value) */ public function setup(\SimpleXMLElement $element, $value, $group = null) { + // Check if the value consist with id:alias, extract the id only + if ($value && str_contains($value, ':')) { + [$id] = explode(':', $value, 2); + $value = (int) $id; + } + $return = parent::setup($element, $value, $group); if (!$return) {