Fixed issue with StructuralEntityType, which was always empty after reloading the page.

We now use the id as option value, this causes that the entities are not compared via ===, but via their id.
This commit is contained in:
Jan Böhmer 2019-08-25 12:39:37 +02:00
parent e7cc53f046
commit 6da2057a7e

View file

@ -50,6 +50,7 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use function foo\func;
/**
@ -87,6 +88,7 @@ class StructuralEntityType extends AbstractType
'show_fullpath_in_subtext' => true, //When this is enabled, the full path will be shown in subtext
'subentities_of' => null, //Only show entities with the given parent class
'disable_not_selectable' => false, //Disable entries with not selectable property
'choice_value' => 'id', //Use the element id as option value and for comparing items
'choice_loader' => function (Options $options) {
return new CallbackChoiceLoader(function () use ($options) {
return $this->getEntries($options);
@ -249,8 +251,6 @@ class StructuralEntityType extends AbstractType
return null;
}
$entity = $this->em->find($options['class'], $value->getID());
return $entity;
return $this->em->find($options['class'], $value->getID());
}
}