* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\UserBundle\Admin\Model; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Form\FormMapper; class GroupAdmin extends AbstractAdmin { /** * {@inheritdoc} */ protected $formOptions = array( 'validation_groups' => 'Registration', ); /** * {@inheritdoc} */ public function getNewInstance() { $class = $this->getClass(); return new $class('', array()); } /** * {@inheritdoc} */ protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('name') ->add('roles') ; } /** * {@inheritdoc} */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('name') ; } /** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. $securityRolesType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') ? 'Sonata\UserBundle\Form\Type\SecurityRolesType' : 'sonata_security_roles'; $formMapper ->tab('Group') ->with('General', array('class' => 'col-md-6')) ->add('name') ->end() ->end() ->tab('Security') ->with('Roles', array('class' => 'col-md-12')) ->add('roles', $securityRolesType, array( 'expanded' => true, 'multiple' => true, 'required' => false, )) ->end() ->end() ; } }