isasimo Posted June 10, 2015 Share Posted June 10, 2015 (edited) I need to set up the birthday as a required field for new customers in prestashop 1.6.0.8. I tried some code from other posts like these ones: https://www.prestashop.com/forums/topic/436711-make-birthday-a-required-field/ or https://www.prestashop.com/forums/topic/276280-setting-required-fields-in-customer-registration/ What I have done until now is:In authentication.tpl: <div class="required form-group"> <label>{l s='Date of Birth'} <sup>*</sup></label> This added the * in the label. But it seems that the “required" class doesn’t affect at all… I added the same in both places from this file. And also in these other files:identity.tplorder-opc-new-account.tplin classes/Customer.php: 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true), With this the birthday is a required field, but even when the field is not empty it still says "there is an error, the birthday is required”. And the user can not sign up (attached a screenshot).Any ideas about that? Everything will be welcome with a big hurrah! Edited June 10, 2015 by isasimo (see edit history) 1 Link to comment Share on other sites More sharing options...
isasimo Posted June 10, 2015 Author Share Posted June 10, 2015 (edited) I already solved, thanks to this topic:https://www.prestashop.com/forums/topic/390975-solucionado-poner-fecha-de-nacimiento-obligatoria/?hl=%2Bbirthday+%2Brequired&do=findComment&comment=1911097 What you need to add in controllers/AuthController.php this line: $customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']); // Preparing customer $customer = new Customer(); $customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']); $lastnameAddress = Tools::getValue('lastname'); $firstnameAddress = Tools::getValue('firstname'); $_POST['lastname'] = Tools::getValue('customer_lastname'); $_POST['firstname'] = Tools::getValue('customer_firstname'); $addresses_types = array('address'); Edited June 10, 2015 by isasimo (see edit history) 2 Link to comment Share on other sites More sharing options...
JDub1337 Posted February 7, 2016 Share Posted February 7, 2016 Thank you for posting this up! I was going crazy trying to link the two together and as it turns out it is the AuthController.php file addition under the controllers/front folder that did the trick. I am also adding in a minimum registered birthday of 18 years and older for other reasons. Any idea where the error message "birthday is invalid" when no birthday is selected or is under 18 years or older is located? I have gone through and made the changes for the birth year so it works but the error message is not correct. Thanks. JDub 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