13. Form Types

4.x version
Maintained Unmaintained
2.x

13. Form Types

13.2. Types options

13.2.1. General

  • label: You can set the label option to false if you don't want to show it:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    // src/Admin/PageAdmin.php
    
    use Sonata\AdminBundle\Form\FormMapper;
    use Sonata\AdminBundle\Admin\AbstractAdmin;
    
    final class PageAdmin extends AbstractAdmin
    {
        protected function configureFormFields(FormMapper $formMapper)
        {
            $formMapper
                ->add('status', null, [
                    'label' => false
                ])
            ;
        }
    }
    

13.2.2. Symfony\Component\Form\Extension\Core\Type\ChoiceType

  • sortable: This option can be added for multiple choice widget to activate select2 sortable:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    // src/Admin/PageAdmin.php
    
    use Sonata\AdminBundle\Form\FormMapper;
    use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
    use Sonata\AdminBundle\Admin\AbstractAdmin;
    
    final class PageAdmin extends AbstractAdmin
    {
        protected function configureFormFields(FormMapper $formMapper)
        {
            $formMapper
                ->add('multiChoices', ChoiceType::class, [
                    'multiple' => true,
                    'sortable' => true,
                ])
            ;
        }
    }
    

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.