The applicant is the base class:
#[ORM\Entity(repositoryClass: ApplicantRepository::class)]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'type', type: Types::STRING)]
#[ORM\DiscriminatorMap([
ApplicantType::COMPANY->value => Company::class,
ApplicantType::PERSON->value => Person::class,
])]
abstract class Applicant
{
#[ORM\Column(type: UuidType::NAME)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected AbstractUid $id;
The Service class has following property:
#[ORM\ManyToOne(targetEntity: Applicant::class, cascade: ['persist'], inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private Applicant $applicant;
Then in the ServiceController
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('applicant', t('backoffice.performances.APPLICANT')),
...
The result is that in the form pages of the ServiceController
, the Applicant
dropdown shows only Person
entities instead of showing Company
ones too.
The id
of the Applicant
is protected as suggested in some GitHub issues, but it didn't fix the issue.
The answer is to add the class form type option as follows:
AssociationField::new('applicant', t('backoffice.performances.APPLICANT'))
->setFormTypeOptions([
'class' => Applicant::class
])