0

i am using sonata admin, i like to show/hide my form using radio buttons and javascript my code :

protected function configureFormFields(FormMapper $formMapper)
    {
         $formMapper
         ->with("Group 1")
            ->add('A', 'choice', array('choices'=>array('g2'=>'g2','g3'=>'g3' )))
            ->add('B')
          ->end()
          ->with("Group 2")
             ->add('C')
             ->add('D')
          ->end();
   ->with("Group 3")
             ->add('E')
             ->add('F')
          ->end();
     }

i like when the user select g2 the group2 display and the group3 hide and when g3 is selected group2 hide and group3 show

1 Answers1

0

you need to do this by overriding the standard base_edit.html.twig which is in sonata admin bundle where you ll put your javascript code.

you ll also need to create a custom CRUD controller ( you can start with original one et customize it ) in order to call your custom template in editAction() instead of the original base_edit.html.twig

here is a tutorial http://sonata-project.org/bundles/admin/master/doc/reference/templates.html

Charles-Antoine Fournel
  • 1,713
  • 1
  • 25
  • 37