title: FOSUserBundle - MultiSelect groups don't work after update
body: <p>I updated composer on my symfony project, and i could not continue to use my custom "SecurityRolesType".</p>
  
  <p>Any idea to update it ? following, codes and errors.</p>
  
  <p>Error : Notice: Array to string conversion 500 Internal Server Error - ContextErrorException</p>
  
  <p>Here a stack screen capture <a href="http://s11.postimg.org/j6nlup4ar/screencapture_stack.jpg" rel="nofollow">http://s11.postimg.org/j6nlup4ar/screencapture_stack.jpg</a></p>
  
  <p>Here a capture of rendered HTML <a href="http://s17.postimg.org/l6mmskmof/Screen_Shot_2015_09_28_at_10_41_19_PM.png" rel="nofollow">http://s17.postimg.org/l6mmskmof/Screen_Shot_2015_09_28_at_10_41_19_PM.png</a></p>
  
  <pre><code>&lt;?php
  
  namespace MYP\UserBundle\Form\Type;
  
  use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\FormInterface;
  use Symfony\Component\Form\FormView;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  use Symfony\Component\OptionsResolver\Options;
  use Sonata\AdminBundle\Admin\Pool;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  
  class SecurityRolesType extends ChoiceType
  {
      protected $pool;
  
      /**
       * @param Pool $pool
       */
      public function __construct(Pool $pool)
      {
          parent::__construct();
          $this-&gt;pool = $pool;
      }
  
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          parent::buildForm($builder, $options);
      }
  
      /**
       * {@inheritdoc}
       */
      public function buildView(FormView $view, FormInterface $form, array $options)
      {
          parent::buildView($view, $form, $options);
  
          $attr = $view-&gt;vars['attr'];
  
          if (isset($attr['class']) &amp;&amp; empty($attr['class'])) {
              $attr['class'] = 'sonata-medium';
          }
  
          $view-&gt;vars['attr'] = $attr;
          $view-&gt;vars['read_only_choices'] = $options['read_only_choices'];
          //$view-&gt;vars['full_name'] = substr($view-&gt;vars['full_name'], 0, -2);
  
      }
  
      /**
       * {@inheritdoc}
       */
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          parent::setDefaultOptions($resolver);
  
          $roles = array();
          $rolesReadOnly = array();
  
          $securityContext = $this-&gt;pool-&gt;getContainer()-&gt;get('security.context');
  
          // get roles from the Admin classes
          foreach ($this-&gt;pool-&gt;getAdminServiceIds() as $id) {
              try {
                  $admin = $this-&gt;pool-&gt;getInstance($id);
              } catch (\Exception $e) {
                  continue;
              }
  
              $isMaster = $admin-&gt;isGranted('MASTER');
              $securityHandler = $admin-&gt;getSecurityHandler();
              // TODO get the base role from the admin or security handler
              $baseRole = $securityHandler-&gt;getBaseRole($admin);
  
              foreach ($admin-&gt;getSecurityInformation() as $role =&gt; $permissions) {
                  $role = sprintf($baseRole, $role);
  
                  if ($isMaster) {
                      // if the user has the MASTER permission, allow to grant access the admin roles to other users
                      $roles[$role] = $role;
                  } elseif ($securityContext-&gt;isGranted($role)) {
                      // although the user has no MASTER permission, allow the currently logged in user to view the role
                      $rolesReadOnly[$role] = $role;
                  }
              }
          }
  
          // get roles from the service container
          foreach ($this-&gt;pool-&gt;getContainer()-&gt;getParameter('security.role_hierarchy.roles') as $name =&gt; $rolesHierarchy) {
  
              if ($securityContext-&gt;isGranted($name)) {
                  $roles[$name] = $name . ': ' . implode(', ', $rolesHierarchy);
  
                  foreach ($rolesHierarchy as $role) {
                      if (!isset($roles[$role])) {
                          $roles[$role] = $role;
                      }
                  }
              }
          }
  
          $resolver-&gt;setDefaults(array(
              'choices' =&gt; function (Options $options, $parentChoices) use ($roles) {
                  return empty($parentChoices) ? $roles : array();
              },
  
              'read_only_choices' =&gt; function (Options $options) use ($rolesReadOnly) {
                  return empty($options['choices']) ? $rolesReadOnly : array();
              },
  
              'data_class' =&gt; null,
  
              //'expanded' =&gt; true
          ));
      }
  
      /**
       * {@inheritdoc}
       */
      public function getParent()
      {
          return 'choice';
      }
  
      /**
       * {@inheritdoc}
       */
      public function getName()
      {
          return 'myp_security_roles';
      }
  }
  </code></pre>