In my project, the form allow user select a Map in a SelectBox. When Map Selectbox change, the options in GroupLayer Selectbox also change depend on which Map is selected. I see exactly Symfony document for my case in: How to Dynamically Modify Forms Using Form Events Howerver, in example code:
$formModifier = function (FormInterface $form, Sport $sport = null) {
$positions = null === $sport ? array() : $sport->getAvailablePositions();
$form->add('position', EntityType::class, array(
'class' => 'App\Entity\Position',
'placeholder' => '',
'choices' => $positions,
));
};
I don't know where the getAvailablePositions()
function should be and what is the returning of this function?. I think this function will be placed in Sport
Entity. Is that right, in Sport
Entity, could I query the Position
Entity with Doctrine ORM queryBuilder?