Change field depending of other in SonataAdminBundle

Viewed 1771

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.

So is it possible to do what i need ?

1 Answers
Related