SonataAdminBundle: Checkbox input not showing (for users : enabled and roles)
Hi, i’m working on a symfony 2.6 project and i have my user entity that extends fos user bundle and i want the admin to be able to enable or disable a user and chose the user’s role in the configuration pannel.
The problem is that the checkbox appear for 0.2 sec and disapear
Sonata version : sonata-project/admin-bundle dev-master 25f7ebe Symfony SonataAdminBundle Symfony version : symfony/symfony v2.6.13 The Symfony PHP framework Php version : PHP 5.5.9-1ubuntu4.16 (cli) (built: Apr 20 2016 14:31:27)
Here is a part of the User class
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
class User extends BaseUser {
public function __construct() {
parent::__construct();
$this->enabled = true;
$this->addRole('ROLE_ADMIN');
$this->setPlainPassword('patate');
}
...
}
Here’s the form in UserAdmin
`protected function configureFormFields(FormMapper $formMapper) {
if (!$this->getSubject()->getId()) {
$formMapper
->with('user_edit_section_general')
->add('username', null, array('label' => 'user_username', 'help' => "user_username_help"))
->end()
;
}
$formMapper
->with('user_edit_section_profile')
->add('firstname', null, array('label' => "user_firstname"))
->add('lastname', null, array('label' => "user_lastname"))
->add('email', null, array('label' => 'user_email'))
->add('service', 'entity', array(
'label' => 'user_service',
'class' => 'IEPAPCGestionBundle:Service',
'required' => false,
'placeholder' => 'user_service_default',
'empty_data' => null,
))
->end()
->with('user_edit_section_management')
->add('roles', 'sonata_security_roles', array(
'expanded' => true,
'multiple' => true,
'required' => true,
'choices' => array(
'ROLE_ADMIN' => 'user_role_admin',
'ROLE_ADMIN_CHIEF' => 'user_role_admin_chief',
'ROLE_ADMIN_RH' => 'user_role_admin_rh',
//'ROLE_ADMIN_FINANCE' => 'user_role_admin_finance',
'ROLE_SUPER_ADMIN' => 'user_role_super_admin',
),
'label' => 'user_edit_roles',
'help' => 'user_roles_help',
))
->add('enabled', 'checkbox', array(
'label' => 'user_enabled',
'help' => 'user_enabled_help',
'required' => false,
))
->end()
;
}`
Thank you and i’m available if you need more information.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 32 (16 by maintainers)
Haha great! @Leouarz did you experience the same problem, by chance ?
@greg0ire it’s a GG by Gregoire ^^ In fact, I fixed the issues https://github.com/sonata-project/SonataAdminBundle/issues/2630#issuecomment-68500112 a loooong time ago and I had this in my templates:
The debug of the block give us the truth!
Now it’s working perfectly… My bad I should saw this sooner…
Thanks a lot for your help!!!
np guys, I will look forward. I will add any information here. btw any help is welcome ^^