Version

Documentation » Admin

14. Form Help Messages and Descriptions »

« 12. Saving hooks

This Page

14. Form Help Messages and Descriptions »

« 12. Saving hooks

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:

    // 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. SymfonyComponentFormExtensionCoreTypeChoiceType

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

    // 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,
                ])
            ;
        }
    }
    

Found a typo? Something is wrong in this documentation? Just fork and edit it!