How to override the UserAdmin form from SonataUserBundle

52 views Asked by At

Here is the thing. I started a SonataProject with SonataAdminBundle (v4.22) and SonataUserBundle (v5.4) to manage user. I would like to override the configureFormFields from the UserAdmin class. I need to add a new bool field, but it isn't displayed. I did not use FosUserBundle.

To do that, I have started to create my own AdminClass UserAdmin, which it extends UserAdmin class from SonataUserBundle. I tried to configure field with configureFormFields.

Here is my function :

<?php

namespace App\Admin;

use Sonata\AdminBundle\Form\FormMapper;

class UserAdmin extends \Sonata\UserBundle\Admin\Model\UserAdmin
{
    protected function configureFormFields(FormMapper $form): void
    {
        parent::configureFormFields($form);
        $form
            ->with('general', ['class' => 'col-md-4'])
                ->add('notification')
            ->end();
    }
}

How to make this override applied ?

Thanks.

0

There are 0 answers