defaliz Posted January 12 Share Posted January 12 (edited) bonjour j'aimerais pour ajouter un 2eme champ email dans le formulaire d'inscription afin de confirmer l'email avez-vous un hook ou modif de template ? merci et bonne journée Edited January 20 by defaliz (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted January 12 Share Posted January 12 Bonjour, voici une piste : https://dev.to/kpodemski/prestashop-adding-new-fields-to-the-customer-form-350k#comment-2hhlb Link to comment Share on other sites More sharing options...
defaliz Posted January 12 Author Share Posted January 12 Merci, effectivement c'est exactement ça... j'ai bien compris qu'il fallait appeller le hook hookAdditionalCustomerFormFields dans un module... mais lequel ? celui de la création du formulaire ? je ne le trouve pas... Link to comment Share on other sites More sharing options...
WEB-FUSION Posted January 13 Share Posted January 13 @defaliz tu crées un petit module pour ajouter ton hook. Link to comment Share on other sites More sharing options...
Mediacom87 Posted January 13 Share Posted January 13 Il y a 21 heures, defaliz a dit : mais lequel ? celui de la création du formulaire ? je ne le trouve pas... Il faut développer un module pour intégrer ce que vous voulez. Des exemples de modules sont fournis dans la documentation. Link to comment Share on other sites More sharing options...
defaliz Posted January 13 Author Share Posted January 13 Merci, donc faut que je me mette à la création de module... est-ce que dans les autres versions de prestashop il y a la confirmation d'email à l'inscription ? c'est une fonction très utilisée partout où il y a necessité de s'inscrire... Link to comment Share on other sites More sharing options...
WEB-FUSION Posted January 13 Share Posted January 13 Non sur PrestaShop jamais vu ça, le mot de passe oui, mais l'email non. Link to comment Share on other sites More sharing options...
defaliz Posted January 13 Author Share Posted January 13 j'ai des clients qui créent des comptes en se trompant sur l'email, ils ne reçoivent jamais le mail d'activation du compte et ils râlent ! 😁 je voudrais éviter ça... Link to comment Share on other sites More sharing options...
WEB-FUSION Posted January 13 Share Posted January 13 En effet, cela peu arrivé. Link to comment Share on other sites More sharing options...
defaliz Posted January 14 Author Share Posted January 14 je passe se post en RESOLU, je vais utiliser ce tuto https://www.h-hennes.fr/blog/2023/01/23/prestashop-ajouter-une-regle-de-validation-sur-un-champ-du-formulaire-de-creation-de-compte/#comment-51973 merci à tous Link to comment Share on other sites More sharing options...
defaliz Posted January 20 Author Share Posted January 20 bonjour j'ai enfin créé mon module pour ajouter la confirmation de l'email on peut le voir ici sur un serveur de test https://presta2.dequ6178.odns.fr/fr/connexion?create_account=1 mail le nouveau champ email2 apparait tout en bas et je ne sais pas comment le remonter sous le 1er email... avez-vous une idée ? merci voici le code <?php if (!defined('_PS_VERSION_')) { exit; } class SecondEmail extends Module { public function __construct() { $this->name = 'secondemail'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'xxxx'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Second Email Field'); $this->description = $this->l('Ajoute un champ de confirmation email au formulaire d\'inscription'); } public function install() { return parent::install() && $this->registerHook('additionalCustomerFormFields') && $this->registerHook('validateCustomerFormFields'); } public function uninstall() { return parent::uninstall(); } public function hookAdditionalCustomerFormFields($params) { return [ (new FormField) ->setName('email2') ->setType('email') ->setRequired(true) ->setLabel($this->l('Confirmez votre email')) ->setMaxLength(255) ]; } public function hookValidateCustomerFormFields($params) { // Debug dans un fichier file_put_contents( _PS_ROOT_DIR_ . '/debug_email.txt', date('Y-m-d H:i:s') . ' - Validation - POST: ' . print_r($_POST, true) . "\n", FILE_APPEND ); foreach ($params['fields'] as $field) { if ($field->getName() === 'email2') { $email2 = $field->getValue(); $email = Tools::getValue('email'); if ($email !== $email2) { $field->addError($this->l('Les deux adresses email doivent être identiques')); return false; } } } return true; } } Link to comment Share on other sites More sharing options...
defaliz Posted January 20 Author Share Posted January 20 bon j'ai trouvé en modifiant customer-form.tpl comme suit : <form action="{block name='customer_form_actionurl'}{$action}{/block}" id="customer-form" class="js-customer-form" method="post"> <div> {block "form_fields"} {foreach from=$formFields item="field"} {block "form_field"} {if $field.name == 'email'} {form_field field=$field} {* On cherche et affiche email2 juste après email *} {foreach from=$formFields item="field2"} {if $field2.name == 'email2'} {form_field field=$field2} {/if} {/foreach} {elseif $field.name != 'email2'} {form_field field=$field} {/if} {/block} {/foreach} {$hook_create_account_form nofilter} {/block} </div> {block name='customer_form_footer'} <footer class="form-footer clearfix"> <input type="hidden" name="submitCreate" value="1"> {block "form_buttons"} <button class="btn btn-primary form-control-submit float-xs-right" data-link-action="save-customer" type="submit"> {l s='Save' d='Shop.Theme.Actions'} </button> {/block} </footer> {/block} </form> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now