Version

Documentation » Admin

14. Form Help Messages and Descriptions »

« 12. Saving hooks

13. Form Types

Note

This article assumes you are using Symfony 4. Using Symfony 2.8 or 3 will require to slightly modify some namespaces and paths when creating entities and admins.

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.
<?php
// src/Admin/PageAdmin.php

use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Admin\AbstractAdmin;

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.
<?php
// src/Admin/PageAdmin.php

use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Sonata\AdminBundle\Admin\AbstractAdmin;

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!