Skip to content

Commit

Permalink
[FIX] 0037983: InvalidArgumentException with lost parent
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Oct 3, 2023
1 parent babb8c8 commit 9d3a708
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ private function initForm(): void
// PARENT
$parent = $f()->field()->select($txt('sub_parent'), $this->repository->getPossibleParentsForFormAndTable())
->withRequired(true);
if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem()) {

$possible_parents = array_keys($this->repository->getPossibleParentsForFormAndTable());

if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem() && in_array($this->item_facade->getParentIdentificationString(), $possible_parents)) {
$parent = $parent->withValue($this->item_facade->getParentIdentificationString());
} else {
$array = array_keys($this->repository->getPossibleParentsForFormAndTable());
$parent = $parent->withValue(reset($array));
$parent = $parent->withValue(reset($possible_parents));
}
$items[self::F_PARENT] = $parent;

Expand Down

0 comments on commit 9d3a708

Please sign in to comment.