Jump to content

Ajouter un substr à $smarty.post.phone pour le formulaire d'inscription


Recommended Posts

Salut !
J'utilise prestashop v.1.5.3
 
Je souhaiterai dans mon formulaire d'inscription pouvoir obliger les utilisateur à entrer 6 chiffres min. et max. dans le champ téléphone et mobile.
 
J'ai trouvé ces 2 lignes dans mon fichier authentication.tpl :

<p class="text">
			<label for="phone">{l s='Home phone'}</label>
			<input type="text" class="text" name="phone" id="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{/if}" />
		</p>
		<p class="text">
			<label for="phone_mobile">{l s='Mobile phone'} {if $onr_phone_at_least}<sup>*</sup>{/if}</label>
			<input type="text" class="text" name="phone_mobile" id="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{/if}" />
		</p>

Est ce que quelqu'un pourrait m'aider à ajouter un substr pour ces 2 champs ?

Merciiii !!

 

Link to comment
Share on other sites

Bon je répond à mon post car j'ai trouvé la solution.

Dans le fichier AuthController.php dans le dossier Controllers, après la ligne :

if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile'))

Entrer :

(pour le mobile)
$digits_mobile = strlen(Tools::getValue('phone_mobile'));
if (Tools::getValue('phone_mobile') AND $digits_mobile !=10)
$this->errors[] = Tools::displayError('Please enter 8 digits for the mobile phone number.');

(pour le fixe)
$digits_home = strlen(Tools::getValue('phone'));
if (Tools::getValue('phone') AND $digits_home !=10)
$this->errors[] = Tools::displayError('Please enter 8 digits for the home phone number.');
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...