Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/release/3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
werrolf committed Feb 4, 2020
2 parents 2196e1a + a9b2711 commit 13928f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/FOM/UserBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ protected function userActionCommon(Request $request, User $user)
'acl_permission' => $this->isGranted('OWNER', $user),
'currentUser' => $this->getUser(),
));
if (!$isNew && !$groupPermission) {
$form->get('username')->setDisabled(true);
}

$form->handleRequest($request);

Expand Down
9 changes: 9 additions & 0 deletions src/FOM/UserBundle/Form/Type/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UserType extends AbstractType
Expand Down Expand Up @@ -69,6 +71,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
}

public function finishView(FormView $view, FormInterface $form, array $options)
{
$user = $form->getData();
$usernameEnabled = $options['group_permission'] || !$user->getId();
$view['username']->vars['disabled'] = !$usernameEnabled;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
Expand Down

0 comments on commit 13928f3

Please sign in to comment.