UserAdmin.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\UserBundle\Admin\Entity;
  11. use Sonata\AdminBundle\Admin\Admin;
  12. use Sonata\AdminBundle\Form\FormMapper;
  13. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  14. use Sonata\AdminBundle\Datagrid\ListMapper;
  15. use Sonata\AdminBundle\Route\RouteCollection;
  16. class UserAdmin extends Admin
  17. {
  18. protected $list = array(
  19. 'username' => array('identifier' => true),
  20. 'email',
  21. 'enabled',
  22. 'locked',
  23. 'createdAt',
  24. );
  25. protected $form = array(
  26. 'username',
  27. 'email',
  28. 'enabled',
  29. 'locked',
  30. 'expired',
  31. 'credentialsExpired',
  32. 'credentialsExpireAt',
  33. 'groups'
  34. );
  35. protected $formGroups = array(
  36. 'General' => array(
  37. 'fields' => array('username', 'email', 'plainPassword')
  38. ),
  39. 'Groups' => array(
  40. 'fields' => array('groups')
  41. ),
  42. 'Management' => array(
  43. 'fields' => array('roles', 'locked', 'expired', 'enabled', 'credentialsExpired', 'credentialsExpireAt')
  44. )
  45. );
  46. protected $formOptions = array(
  47. 'validation_groups' => 'admin'
  48. );
  49. protected $filter = array(
  50. 'username',
  51. 'locked',
  52. 'email',
  53. 'id',
  54. );
  55. public function configureFormFields(FormMapper $formMapper)
  56. {
  57. $formMapper->addType('roles', 'sonata_security_roles', array(
  58. 'multiple' => true,
  59. // 'expanded' => true,
  60. ), array(
  61. 'type' => 'choice'
  62. ));
  63. }
  64. }