From d353ae5ebd36b3e354becce4dcd1a076cea444e3 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Thu, 19 Sep 2024 11:46:15 +0100 Subject: [PATCH 1/3] ensure field is set last on the layout element # Conflicts: # src/fieldlayoutelements/CustomField.php --- src/fieldlayoutelements/CustomField.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fieldlayoutelements/CustomField.php b/src/fieldlayoutelements/CustomField.php index e8db9ecef50..2c7177a5bcc 100644 --- a/src/fieldlayoutelements/CustomField.php +++ b/src/fieldlayoutelements/CustomField.php @@ -35,8 +35,16 @@ class CustomField extends BaseField */ public function __construct(?FieldInterface $field = null, $config = []) { - $this->_field = $field; + // ensure we set the field last, so it has access to other properties that need to be set first + // see https://github.com/craftcms/cms/issues/15752 + if (isset($config['fieldUid'])) { + $fieldUid = $config['fieldUid']; + unset($config['fieldUid']); + $config['fieldUid'] = $fieldUid; + } + parent::__construct($config); + $this->_field = $field; } /** From d5e3ec8c95c4ef7bbfacfaaf1d96a6ec02e00c75 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 20 Sep 2024 15:48:20 -0700 Subject: [PATCH 2/3] Cleanup --- src/fieldlayoutelements/CustomField.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fieldlayoutelements/CustomField.php b/src/fieldlayoutelements/CustomField.php index 2c7177a5bcc..169adc6cfa8 100644 --- a/src/fieldlayoutelements/CustomField.php +++ b/src/fieldlayoutelements/CustomField.php @@ -37,9 +37,8 @@ public function __construct(?FieldInterface $field = null, $config = []) { // ensure we set the field last, so it has access to other properties that need to be set first // see https://github.com/craftcms/cms/issues/15752 - if (isset($config['fieldUid'])) { - $fieldUid = $config['fieldUid']; - unset($config['fieldUid']); + $fieldUid = ArrayHelper::remove($config, 'fieldUid'); + if ($fieldUid) { $config['fieldUid'] = $fieldUid; } From d30611a1b43d689fc74e5a06dcf7c4bfceb4b01a Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 20 Sep 2024 15:51:52 -0700 Subject: [PATCH 3/3] Release note [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50fd582ad8c..cfac9abe837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Auto-generated handles, slugs, etc. now update immediately when the source input is changed. ([#15754](https://github.com/craftcms/cms/issues/15754)) - Fixed a bug where Table fields’ Default Values table could lose existing rows if they only consisted of Dropdown columns without configured options. +- Fixed a bug where custom fields’ `required` properties were always `false`. ([#15752](https://github.com/craftcms/cms/issues/15752)) ## 4.12.3 - 2024-09-14