Skip to content

Commit 6ea974b

Browse files
committedDec 3, 2024·
bug #6601 Fix create form when entity id not set (alexndlm)
This PR was squashed before being merged into the 4.x branch. Discussion ---------- Fix create form when entity id not set Fix for #6549 Commits ------- 9fb215f Fix create form when entity id not set
2 parents 3513817 + 9fb215f commit 6ea974b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/Dto/EntityDto.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
1313
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
1414
use Symfony\Component\ExpressionLanguage\Expression;
15+
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
1516
use Symfony\Component\PropertyAccess\PropertyAccess;
1617

1718
/**
@@ -103,7 +104,11 @@ public function getPrimaryKeyValue(): mixed
103104
->enableExceptionOnInvalidIndex()
104105
->getPropertyAccessor();
105106

106-
$primaryKeyValue = $propertyAccessor->getValue($this->instance, $this->primaryKeyName);
107+
try {
108+
$primaryKeyValue = $propertyAccessor->getValue($this->instance, $this->primaryKeyName);
109+
} catch (UninitializedPropertyException $exception) {
110+
$primaryKeyValue = null;
111+
}
107112

108113
return $this->primaryKeyValue = $primaryKeyValue;
109114
}

0 commit comments

Comments
 (0)
Please sign in to comment.