Skip to content

Commit

Permalink
fix entity->isLoaded
Browse files Browse the repository at this point in the history
  • Loading branch information
ibelar committed Sep 7, 2023
1 parent dd2254a commit c43aca7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Service/Atk/FormControlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function factorySelect(Field $field): Control
$control->onSetValue(function ($value) use ($refModel) {
if ($value) {
$refEntity = $refModel->tryLoad($value);
if ($refEntity->isLoaded()) {
if ($refEntity) {
$selectableItems[$value] = $refEntity->get($refEntity->titleField);
}
}
Expand All @@ -236,7 +236,7 @@ protected function factorySelect(Field $field): Control
$items = self::getSelectItems($refModel);
if ($value && !in_array($value, array_column($items, Control\Select::KEY), true)) {
$refEntity = $refModel->tryLoad($value);
if ($refEntity->isLoaded()) {
if ($refEntity) {
$newItems = [Control\Select::KEY => $value, Control\Select::LABEL => $refEntity->get($refEntity->titleField)];
array_unshift($items, $newItems);
}
Expand Down

0 comments on commit c43aca7

Please sign in to comment.