security = $security; $this->trans = $trans; } public function buildForm(FormBuilderInterface $builder, array $options) { /** @var StructuralDBElement $entity */ $entity = $options['data']; $is_new = $entity->getID() === null; $builder ->add('name', TextType::class, [ 'empty_data' => '', 'label' => $this->trans->trans('user.username.label'), 'attr' => ['placeholder' => $this->trans->trans('user.username.placeholder')], 'disabled' => !$this->security->isGranted('edit_username', $entity), ]) ->add('group', StructuralEntityType::class, [ 'class' => Group::class, 'required' => false, 'label' => $this->trans->trans('group.label'), 'disable_not_selectable' => true, 'disabled' => !$this->security->isGranted('change_group', $entity), ]) ->add('first_name', TextType::class, [ 'empty_data' => '', 'label' => $this->trans->trans('user.firstName.label'), 'attr' => ['placeholder' => $this->trans->trans('user.firstName.placeholder')], 'required' => false, 'disabled' => !$this->security->isGranted('edit_infos', $entity), ]) ->add('last_name', TextType::class, [ 'empty_data' => '', 'label' => $this->trans->trans('user.lastName.label'), 'attr' => ['placeholder' => $this->trans->trans('user.lastName.placeholder')], 'required' => false, 'disabled' => !$this->security->isGranted('edit_infos', $entity), ]) ->add('email', TextType::class, [ 'empty_data' => '', 'label' => $this->trans->trans('user.email.label'), 'attr' => ['placeholder' => $this->trans->trans('user.email.placeholder')], 'required' => false, 'disabled' => !$this->security->isGranted('edit_infos', $entity), ]) ->add('department', TextType::class, [ 'empty_data' => '', 'label' => $this->trans->trans('user.department.label'), 'attr' => ['placeholder' => $this->trans->trans('user.department.placeholder')], 'required' => false, 'disabled' => !$this->security->isGranted('edit_infos', $entity), ]) ; /*->add('comment', CKEditorType::class, ['required' => false, 'label' => 'comment.label', 'attr' => ['rows' => 4], 'help' => 'bbcode.hint', 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]); */ $this->additionalFormElements($builder, $options, $entity); //Buttons $builder->add('save', SubmitType::class, [ 'label' => $is_new ? $this->trans->trans('user.create') : $this->trans->trans('user.edit.save'), 'attr' => ['class' => $is_new ? 'btn-success' : ''] ]) ->add('reset', ResetType::class, [ 'label' => $this->trans->trans('entity.edit.reset') ]); } protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity) { //Empty for Base } }