From 54e6eef53b257fbd7c2ca7c35cba376d9910d487 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Sat, 17 Feb 2024 06:13:49 -0800 Subject: [PATCH] Cleanup --- src/elements/User.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/elements/User.php b/src/elements/User.php index 9c5f80e0088..dc51beee694 100644 --- a/src/elements/User.php +++ b/src/elements/User.php @@ -973,18 +973,15 @@ public function setAttributes($values, $safeOnly = true): void } } - if (array_key_exists('firstName', $values) || array_key_exists('lastName', $values)) { - $this->fullName = null; - } - - // if we're set to show full name field, and it's empty, clear out first and last names too - if ( - !Craft::$app->getConfig()->getGeneral()->showFirstAndLastNameFields && - array_key_exists('fullName', $values) && - empty(trim($values['fullName'])) - ) { + if (array_key_exists('fullName', $values)) { + // Clear out the first and last names. + // They'll get reset from prepareNamesForSave() if fullName isn't empty. $this->firstName = null; $this->lastName = null; + } elseif (array_key_exists('firstName', $values) || array_key_exists('lastName', $values)) { + // Clear out the full name. + // It'll get reset from prepareNamesForSave() if the first/last names aren't empty. + $this->fullName = null; } parent::setAttributes($values, $safeOnly);