giwrgos88 Posted August 10, 2015 Share Posted August 10, 2015 Hello, I'm looking a method to make birthday field on the registration form required because I want to add some warnings to categories which needs age restrictions. I don't want on the next update of prestashop this modification to be lost. I'm working on 1.6.1.0 Thank you Link to comment Share on other sites More sharing options...
Soulburst Posted August 10, 2015 Share Posted August 10, 2015 Well.. Go to Localization > Pick the country you want to edit > Format Addresses Link to comment Share on other sites More sharing options...
giwrgos88 Posted August 10, 2015 Author Share Posted August 10, 2015 Well.. Go to Localization > Pick the country you want to edit > Format Addresses Is it this on a wrong post? Link to comment Share on other sites More sharing options...
Soulburst Posted August 10, 2015 Share Posted August 10, 2015 Is it this on a wrong post? Sorry didn't understood your question Link to comment Share on other sites More sharing options...
giwrgos88 Posted August 10, 2015 Author Share Posted August 10, 2015 Sorry didn't understood your question You reply is for the age to make it required or you post it on a wrong section? Link to comment Share on other sites More sharing options...
Soulburst Posted August 10, 2015 Share Posted August 10, 2015 (edited) I answer because you can set on there your required fields. Well i didn't read it right.... About categories ages... sry Edited August 10, 2015 by Soulburst (see edit history) Link to comment Share on other sites More sharing options...
giwrgos88 Posted August 10, 2015 Author Share Posted August 10, 2015 I answer because you can set on there your required fields. ok it looks like the birthday is required but on the form is not Link to comment Share on other sites More sharing options...
Soulburst Posted August 10, 2015 Share Posted August 10, 2015 (edited) ok it looks like the birthday is required but on the form is not But it's opnly for adresses... So i think it isn't that what you want... :/ Edited August 10, 2015 by Soulburst (see edit history) Link to comment Share on other sites More sharing options...
jsanchez67 Posted August 17, 2016 Share Posted August 17, 2016 (edited) Hello, You can do this by doing two overrides. The first one is the Customer.php. We have to set the birthday field to require true. <?php //overrides/classes/Customer.php // Set the birthday to required true class Customer extends CustomerCore { public function __construct($id = null) { self::$definition['fields']['birthday'] = array( 'type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true ); parent::__construct($id); } } The second is the front controller AuthController.php, if you don't do this one, you will never be able to create an account. Prestashop check if the required fields are in the POST, the birthday is calculated after so he won't be there at the control. So we had it before the control. <?php // overrides/controllers/front/AuthController.php // Add the birthday to the POST to handle valideController class AuthController extends AuthControllerCore { protected function processSubmitAccount() { $birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); if ($birthday) { $GLOBALS['_POST']['birthday'] = $birthday; } return parent::processSubmitAccount(); } } And don't forget to delete the file in cache/class_index.php (it will be generated automatically), otherwise, those files won't be loaded by Prestashop. Edited August 17, 2016 by jsanchez67 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 17, 2016 Share Posted August 17, 2016 step by step guide is available here: make birthday field required Link to comment Share on other sites More sharing options...
giwrgos88 Posted August 22, 2016 Author Share Posted August 22, 2016 step by step guide is available here: make birthday field required thanks Link to comment Share on other sites More sharing options...
mr_absinthe Posted August 4, 2017 Share Posted August 4, 2017 step by step guide is available here: make birthday field required Would it be possible to update your step by step guide to v1.7.2 please? It doesn't seem to work, 500 server error after uploading two edited files. Link to comment Share on other sites More sharing options...
backamblock Posted July 22, 2018 Share Posted July 22, 2018 On 17.8.2016 at 11:20 AM, jsanchez67 said: Hello, You can do this by doing two overrides. The first one is the Customer.php. We have to set the birthday field to require true. <?php //overrides/classes/Customer.php // Set the birthday to required true class Customer extends CustomerCore { public function __construct($id = null) { self::$definition['fields']['birthday'] = array( 'type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true ); parent::__construct($id); } } The second is the front controller AuthController.php, if you don't do this one, you will never be able to create an account. Prestashop check if the required fields are in the POST, the birthday is calculated after so he won't be there at the control. So we had it before the control. <?php // overrides/controllers/front/AuthController.php // Add the birthday to the POST to handle valideController class AuthController extends AuthControllerCore { protected function processSubmitAccount() { $birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); if ($birthday) { $GLOBALS['_POST']['birthday'] = $birthday; } return parent::processSubmitAccount(); } } And don't forget to delete the file in cache/class_index.php (it will be generated automatically), otherwise, those files won't be loaded by Prestashop. Could someone please explain to me where to insert this code in PS1.7.4.1 please? when i go to .../override/classes there are only a bunch of folders which all only have "index.php" files in them but i can not find the customer.php or authcontroller. thank you for helping a noob getting better 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