Jump to content

Prestashop 1.7 confirmation mot de passe lors de la creation nouveau compte


Jluis

Recommended Posts

Bonjour , 

je voudrais afficher une deuxième input de confirmation de mot de passe lors de la création d'un nouveau compte . suffit t-il de dupliquer l'input de mot de passe  et tester si les deux valeurs sont égaux ??

Merci d'avance

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Hello tout le monde, voici la solution

Fichiers

/classes/form/CustomerFormatter.php

/classes/form/CustomerForm.php

Ouvrir CustomerFormatter.php et chercher

$format['email'] = (new FormField())

au dessus de 

        if ($this->ask_for_new_password) {
            $format['new_password'] = (new FormField())
                ->setName('new_password')
                ->setType('password')
                ->setLabel(
                    $this->translator->trans(
                        'New password', [], 'Shop.Forms.Labels'
                    )
                )
            ;
        }

mettre : 

		$format['conf_password'] = (new FormField)
			->setName('conf_password')
			->setType('password')
			->setLabel(
				$this->translator->trans(
					'Confirm password', [], 'Shop.Forms.Labels'
				)
			)
			->setRequired(true)
		;

 

ensuite  CustomerForm.php et chercher 

public function validate()

après le code :

	$emailField = $this->getField('email');
        $id_customer = Customer::customerExists($emailField->getValue(), true, true);
        $customer = $this->getCustomer();
        if ($id_customer && $id_customer != $customer->id) {
            $emailField->addError($this->translator->trans(
                'The email is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'
            ));
        }

mettre :

//Confirm password - check if is the same
		$passwField = $this->getField('password');
		$confPasswField = $this->getField('conf_password');
		$passwordValue = $passwField->getValue();
		$confPasswValue = $confPasswField->getValue();
		if ($passwordValue != $confPasswValue) {
            $confPasswField->addError($this->translator->trans(
                "The password and the confirmation password don't match", array(), 'Shop.Notifications.Error'
            ));
        }

 

ensuite mettre les fichiers dans :

/override/classes/form/

VIDER LE CACHE

Edited by stevent (see edit history)
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...