public function testSubmit() { $group = new TestGroup('foo'); $form = $this->factory->create(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\GroupFormType'), $group); $formData = array('name' => 'bar'); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($group, $form->getData()); $this->assertEquals('bar', $group->getName()); }
public function testSubmit() { $user = new TestUser(); $form = $this->factory->create(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ResettingFormType'), $user); $formData = array('plainPassword' => array('first' => 'test', 'second' => 'test')); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($user, $form->getData()); $this->assertEquals('test', $user->getPlainPassword()); }
public function testSubmit() { $user = new TestUser(); $form = $this->factory->create(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ProfileFormType'), $user); $formData = array('username' => 'bar', 'email' => '*****@*****.**'); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($user, $form->getData()); $this->assertEquals('bar', $user->getUsername()); $this->assertEquals('*****@*****.**', $user->getEmail()); }
public function buildForm(FormBuilderInterface $builder, array $options) { // add your custom field $builder->remove('username'); $builder->remove('email'); $builder->remove('plainPassword'); $builder->add('firstName', null, ['label' => 'Voornaam', 'constraints' => [new NotBlank()]]); $builder->add('lastName', null, ['label' => 'Achternaam', 'constraints' => [new NotBlank()]]); $builder->add('phone', null, ['label' => 'Telefoon', 'constraints' => [new NotBlank(), new Length(["min" => 10, "max" => 10])]]); $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle')); $builder->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password'), 'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch')); }
public function testSubmit() { $user = new TestUser(); $form = $this->factory->create(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\RegistrationFormType'), $user); $formData = array('username' => 'bar', 'email' => '*****@*****.**', 'plainPassword' => array('first' => 'test', 'second' => 'test')); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($user, $form->getData()); $this->assertEquals('bar', $user->getUsername()); $this->assertEquals('*****@*****.**', $user->getEmail()); $this->assertEquals('test', $user->getPlainPassword()); }
/** * * @Route("/user/{id}/edit", name="user.edit") */ public function editUserAction($id, Request $request) { $userManager = $this->get('fos_user.user_manager'); $user = $userManager->findUserBy(array('id' => $id)); // test if user exist before modified it if (!$user) { throw $this->createNotFoundException('user not found'); } $form = $this->createFormBuilder($user)->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'disabled' => true))->add('displayName', null, array('label' => 'Display name'))->add('circles', ObjectPickerType::class, ['multiple' => TRUE, 'type' => $this->container->getParameter('circles_object'), 'dynamicLoading' => true])->add('enabled')->add('locked')->add('expiresAt', DateType::class, array('required' => FALSE, 'widget' => 'single_text', 'format' => 'd/M/y', 'html5' => FALSE, 'attr' => array('class' => 'datepicker', 'data-date-format' => 'dd/mm/yyyy', 'data-today-highlight' => FALSE, 'data-week-start' => 1, 'data-days-of-week-highlighted' => true, 'data-days-of-week-disabled' => false, 'data-multidate' => FALSE)))->add('allowedToConfigureWysiwyg', CheckboxType::class, ['required' => false])->add('wysiwygProfile', ChoiceType::class, ['required' => true, 'choices' => ['Standard' => 'standard', 'Light' => 'light', 'Full' => 'full', 'Custom' => 'custom']])->add('wysiwygOptions', TextareaType::class, ['required' => false, 'label' => 'WYSIWYG custom options', 'attr' => ['rows' => 8]])->add('roles', ChoiceType::class, array('choices' => $this->getExistingRoles(), 'label' => 'Roles', 'expanded' => true, 'multiple' => true, 'mapped' => true))->add('update', SubmitEmsType::class, ['attr' => ['class' => 'btn-primary btn-sm '], 'icon' => 'fa fa-save'])->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $continue = TRUE; $continue = $this->userExist($user, 'edit', $form); if ($continue) { $userManager->updateUser($user, false); $this->getDoctrine()->getManager()->flush(); $this->addFlash('notice', 'User was modified!'); return $this->redirectToRoute('user.index'); } } return $this->render('user/edit.html.twig', array('form' => $form->createView(), 'user' => $user)); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'attr' => array('class' => 'form-control'), 'label_attr' => array('class' => 'form-control-label')))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password', 'attr' => array('class' => 'form-control'), 'label_attr' => array('class' => 'form-control-label')), 'second_options' => array('label' => 'form.password_confirmation', 'attr' => array('class' => 'form-control'), 'label_attr' => array('class' => 'form-control-label')), 'invalid_message' => 'fos_user.password.mismatch'))->add('email', null, array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle', 'attr' => array('class' => 'form-control'), 'label_attr' => array('class' => 'form-control-label')))->add('accept_toc', 'checkbox', array('label' => 'I accept terms & conditions', 'attr' => array('class' => 'form-control', 'help' => 'text help'), 'label_attr' => array('class' => 'form-control-label'), 'mapped' => FALSE, "constraints" => new IsTrue(array("message" => "Please accept the Terms and conditions in order to register")))); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'Email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'Username', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'Password'), 'second_options' => array('label' => 'Confirm the password'), 'invalid_message' => 'The passwords mismatch'))->add('firstname')->add('lastname'); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', null, ['label' => "Nume si Prenume", 'required' => false, 'attr' => ['class' => 'form-control']])->add('username', null, ['label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'attr' => ['class' => 'form-control']])->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), ['label' => "Email", 'required' => true, 'attr' => ['class' => 'form-control']])->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), ['type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => ['translation_domain' => 'FOSUserBundle'], 'first_options' => ['label' => 'form.password', 'attr' => ['class' => 'form-control']], 'second_options' => ['label' => 'form.password_confirmation', 'attr' => ['class' => 'form-control']], 'invalid_message' => 'fos_user.password.mismatch'])->add('submit', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType', ['attr' => ['class' => 'btn btn-lg btn-primary btn-block']]); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'E-mail', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'Nombre de usuario', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'Contraseña'), 'second_options' => array('label' => 'Confirmar contraseña'), 'invalid_message' => 'Error, las contraseñas no coinciden'))->add('roles', 'choice', array('label' => ' ', 'attr' => array('hidden' => true), 'choices' => array('ROLE_ADMIN' => 'ADMINISTRADOR', 'ROLE_SUPERADMIN' => 'SUPERADMINISTRADOR', 'ROLE_USER' => 'USUARIO'), 'multiple' => true)); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('current_password', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), array('label' => 'form.current_password', 'translation_domain' => 'FOSUserBundle', 'mapped' => false, 'constraints' => new UserPassword())); $builder->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.new_password'), 'second_options' => array('label' => 'form.new_password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch')); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstname', null, array('label' => 'Prénom', 'translation_domain' => 'FOSUserBundle'))->add('lastname', null, array('label' => 'Nom', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'Nom utilisateur', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'E-mail', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'Mot de passe'), 'second_options' => array('label' => 'Confirmation mot de passe'), 'invalid_message' => 'Les mots de passes ne correspondent pas')); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('blogDisplayName', 'text', array('label' => 'Display Name:', 'data' => isset($options['data']['blogDisplayName']) ? $options['data']['blogDisplayName'] : null, 'attr' => array('class' => 'form-control form-control--lg margin--b', 'placeholder' => 'Enter blog user name')))->add('role', 'choice', array('label' => 'Roles?', 'expanded' => true, 'choices' => $this->blogUserHandler->getBlogRolesArray(), 'data' => isset($options['data']['role']) ? $options['data']['role'] : null))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'Email:', 'translation_domain' => 'FOSUserBundle', 'attr' => array('class' => 'form-control form-control--lg margin--b', 'placeholder' => 'Enter user email')))->add('username', null, array('label' => 'Username:'******'translation_domain' => 'FOSUserBundle', 'attr' => array('class' => 'form-control form-control--lg margin--b', 'placeholder' => 'Enter username')))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'Password:'******'attr' => array('class' => 'form-control form-control--lg margin--b')), 'second_options' => array('label' => 'Password Cconfirmation', 'attr' => array('class' => 'form-control form-control--lg margin--b')), 'invalid_message' => 'fos_user.password.mismatch', 'attr' => array('class' => 'form-control form-control--lg margin--b')))->add('Save', 'submit', array('attr' => array('class' => 'btn btn-md btn-primary btn-wide--xl flright--responsive-mob margin--b'))); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType')); $builder->add('password', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), array('label' => 'form.current_password', 'translation_domain' => 'FOSUserBundle', 'mapped' => false, 'constraints' => new UserPassword())); }
private function addGroupSection(ArrayNodeDefinition $node) { $node->children()->arrayNode('group')->canBeUnset()->children()->scalarNode('group_class')->isRequired()->cannotBeEmpty()->end()->scalarNode('group_manager')->defaultValue('fos_user.group_manager.default')->end()->arrayNode('form')->addDefaultsIfNotSet()->fixXmlConfig('validation_group')->children()->scalarNode('type')->defaultValue(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\GroupFormType'))->end()->scalarNode('name')->defaultValue('fos_user_group_form')->end()->arrayNode('validation_groups')->prototype('scalar')->end()->defaultValue(array('Registration', 'Default'))->end()->end()->end()->end()->end()->end(); }
/** * Builds the embedded form representing the user. * * @param FormBuilderInterface $builder * @param array $options */ protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('nom', 'text', array('label' => 'form.nom', 'translation_domain' => 'FOSUserBundle'))->add('prenom', 'text', array('label' => 'form.prenom', 'translation_domain' => 'FOSUserBundle'))->add('dateNaissance', 'birthday', array('label' => 'form.birthday', 'translation_domain' => 'FOSUserBundle'))->add('photo', 'file', array('label' => 'form.photo', 'translation_domain' => 'FOSUserBundle', 'required' => false, 'constraints' => [new File(['maxSize' => '2M', 'maxSizeMessage' => 'Le poid de l\'image est trop grand, il ne doit pas dépasser {{ limit }} {{ sufix }}.', 'mimeTypes' => ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/bmp'], 'mimeTypesMessage' => 'Le type de l\'image n\'est pas supporté, veuillez choisir une image ayant pour extension : .png, .jpeg, .jpg, .gif ou .bmp.'])]))->add('sexe', 'choice', array('label' => 'form.sexe', 'choices' => array('homme' => 'homme', 'femme' => 'femme'), 'translation_domain' => 'FOSUserBundle'))->add('adresseLieuResidence', 'text', array('required' => false, 'constraints' => new Adresse())); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('phone', null, array('label' => 'Телефон'))->add('date_of_birth', 'birthday', array('label' => 'День рождения'))->add('firstname', null, array('label' => 'Имя'))->add('lastname', null, array('label' => 'Фамилия')); }
private function buildPasswordForm(Account $account) { return $this->get('form.factory')->createNamedBuilder('Account', FormType::class, $account)->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.new_password'), 'second_options' => array('label' => 'form.new_password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'))->getForm(); }
/** * Builds the embedded form representing the user. * * @param FormBuilderInterface $builder * @param array $options */ protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle')); }
public function testUserLoadFormClassWithDefaults() { $this->createEmptyConfiguration(); $this->assertParameter(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ProfileFormType'), 'fos_user.profile.form.type'); $this->assertParameter(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\RegistrationFormType'), 'fos_user.registration.form.type'); $this->assertParameter(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ChangePasswordFormType'), 'fos_user.change_password.form.type'); $this->assertParameter(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ResettingFormType'), 'fos_user.resetting.form.type'); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('name', null, array('required' => true, 'label' => 'form.firstname', 'translation_domain' => 'FOSUserBundle'))->add('firstname', null, array('required' => true, 'label' => 'form.name', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('information', InformationType::class, array('label' => null, 'required' => false, 'translation_domain' => 'FOSUserBundle'))->add('birthday', BirthdayType::class, array('placeholder' => array('year' => 'année', 'month' => 'mois', 'day' => 'jour'), 'format' => 'dd-MM-yyyy', 'widget' => 'choice')); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', null, array('label' => 'neues Passwort', 'required' => false))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('roles', ChoiceType::class, array('label' => 'Rollen', 'choices' => $this->choices['roles'], 'choice_label' => function ($value, $key, $index) { return $value; }, 'choice_translation_domain' => 'FOSUserBundle', 'multiple' => true, 'expanded' => true, 'choices_as_values' => true)); }
/** * Builds the embedded form representing the user. * * @param FormBuilderInterface $builder * @param array $options */ protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('about', 'text', ['required' => false])->add('phone', 'text', ['required' => false])->add('vk', 'text', ['required' => false])->add('facebook', 'text', ['required' => false])->add('avatar', 'sonata_media_type', ['required' => false, 'provider' => 'sonata.media.provider.image', 'context' => 'default'])->add('twitter', 'text', ['required' => false]); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('tipo_documento', 'entity', array('label' => 'Tipo de documento', 'class' => 'AppBundle:Listas', 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('l')->where('l.dominio = :dominio')->andWhere('l.active = 1')->setParameter('dominio', 'tipo_documento')->orderBy('l.orden', 'ASC'); }))->add('numero_documento', 'text', array('label' => 'Número de documento'))->add('primer_apellido')->add('segundo_apellido', 'text', array('required' => false))->add('primer_nombre')->add('segundo_nombre', 'text', array('required' => false))->add('telefono_fijo', 'text', array('label' => 'Teléfono fijo'))->add('telefono_celular', 'text', array('label' => 'Teléfono celular'))->add('municipio', 'entity', array('class' => 'AppBundle:Municipio'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password'), 'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch')); }
/** * Builds the embedded form representing the user. * * @param FormBuilderInterface $builder * @param array $options */ protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('telephone', 'text', array('label' => 'Telephone'))->add('adresse', 'text', array('label' => 'Adresse'))->add('codePostal', 'text', array('label' => 'Code postal'))->add('ville', 'text', array('label' => 'Ville')); }
public function deleteUserAction(Request $request, $id) { $formBuilder = $this->createFormBuilder(); $formBuilder->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.new_password'), 'second_options' => array('label' => 'form.new_password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch')); $form = $formBuilder->getForm(); if ($request->getMethod() == "POST") { $form->bind($request); if ($form->isValid()) { $data = $form->getData(); $data = $data["plainPassword"]; $user = $this->getUser(); if ($user->getId() == $id) { $encoder_service = $this->get('security.encoder_factory'); $encoder = $encoder_service->getEncoder($user); $encoded_pass = $encoder->encodePassword($data, $user->getSalt()); if ($encoded_pass == $user->getPassword()) { //Script de suppresion $user->setUsername("Anonymous" . $user->getId()); $user->setUsernameCanonical("anonymous" . $user->getId()); $user->setEmail($user->getUsername() . "@deleteUser.playrion.com"); $user->setEmailCanonical($user->getUsernameCanonical() . "@nothing.playrion.com"); $user->setEnabled(0); $user->setPassword("anonymous" . $user->getId()); $user->setLocked(1); $user = $this->getUser(); $em = $this->getDoctrine()->getManager(); // Replace All user Subject by a Anonymous user $repository = $em->getRepository('PlayrionCommunityBundle:Subject'); $listSubject = $repository->findBy(array('user' => $user->getId())); foreach ($listSubject as $subject) { $subject->setAuthor($user->getUsername()); } $em->flush(); // Replace All user into Proposition by a Anonymous user $repository = $em->getRepository('PlayrionCommunityBundle:Proposition'); $listProposition = $repository->findBy(array('user' => $user->getId())); foreach ($listProposition as $proposition) { $proposition->setAuthor($user->getUsername()); } $em->flush(); return $this->redirect($this->generateUrl('fos_user_security_logout')); } } } } if ($this->getUser() != null) { $em = $this->getDoctrine()->getManager(); //On récupère l'id de l'utilisateur $id = $this->getUser()->getId(); //On récupère le profil pour mettre à jour la langue $repository = $em->getRepository("PlayrionCommunityBundle:Profil"); $languageChange = $repository->findBy(array('user' => $id)); if ($languageChange) { if (null !== $languageChange[0]->getLanguage()) { $this->get('request')->attributes->set('_locale', null); $this->get('session')->set('_locale', $languageChange[0]->getLanguage()); } } } return $this->render('PlayrionCommunityBundle:Profil:deleteUser.html.twig', array('formDeleteUser' => $form->createView())); }
/** * Formulaire d'entité User * @param $builder <i>FormBuilderInterface<i/> * @param $options <i>Array</i> */ public function buildForm(FormBuilderInterface $builder, array $options) { //////// A OPTIMISER $builder->add('prenom', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType'), array('label' => 'form.prenom', 'translation_domain' => 'FOSUserBundle', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'Prénom', 'class' => 'form-control')))->add('nom', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType'), array('label' => 'form.nom', 'translation_domain' => 'FOSUserBundle', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'Nom', 'class' => 'form-control')))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'Adresse email', 'class' => 'form-control')))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'form.username', 'class' => 'form-control')))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'form.password', 'class' => 'form-control')), 'second_options' => array('label' => 'form.password_confirmation', 'label_attr' => array('class' => 'sr-only'), 'attr' => array('placeholder' => 'form.password_confirmation', 'class' => 'form-control')), 'invalid_message' => 'fos_user.password.mismatch'))->add('dateNaissance', 'date', ['translation_domain' => 'FOSUserBundle', 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', 'attr' => ['class' => 'form-control input-inline datepicker', 'placeholder' => 'form.birthday', 'data-provide' => 'datepicker', 'data-date-format' => 'dd-mm-yyyy']])->add('sexe', 'choice', array('choices' => array('homme' => ' Homme', 'femme' => ' Femme'), 'multiple' => false, 'expanded' => true)); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', 'text', ['label_attr' => ['class' => 'profile-form__label'], 'attr' => ['class' => 'profile-form__input']])->add('email', 'email', ['label_attr' => ['class' => 'profile-form__label'], 'attr' => ['class' => 'profile-form__input']])->add('current_password', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), ['label_attr' => ['class' => 'profile-form__label'], 'label' => 'form.current_password', 'translation_domain' => 'FOSUserBundle', 'mapped' => false, 'constraints' => new UserPassword(), 'attr' => ['class' => 'profile-form__input']]); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('email', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType'), array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType'), array('type' => LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.new_password'), 'second_options' => array('label' => 'form.new_password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'))->add('enabled', 'checkbox', array('label' => 'Habilitado?')); }
/** * @see Symfony\Component\Form\AbstractType::getParent() */ public function getParent() { return LegacyFormHelper::getType('Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType'); }