In a Symfony3 project, i have a SonataAdminBundle form like this :
protected function configureFormFields(FormMapper $formMapper) {
$formMapper->add('rentalTime', 'choice', array(
'label' => 'Durée de location',
'multiple' => false,
'choices' => array(
'3H' => '3',
'24H' => '24',
)
));
$formMapper->add('rentalTimeType', 'choice', array(
'label' => 'Type de durée de location',
'multiple' => false,
'choices' => array(
'Heure(s)' => 'H',
'Plage de jours' => 'R'
)
));
.
.
.
When i change the value of rentalTime i want to change the value of rentaltimeType. Example: If i select 24H in rentalTime field and automatically the rentalTimeType change for 'Plage de jours'.
I've read a lot of topic with the use of $subject but it's not exactly what i need.
- change row color in sonata admin bundle dependent on a value of a field
- Correct way to use FormEvents to customise fields in SonataAdmin
- Sonata User Admin - Custom field dependency
So is it possible to do what i need ?