Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 17, 2024
1 parent bc4c963 commit 54e6eef
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/elements/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 54e6eef

Please sign in to comment.