tsandeep Posted June 30, 2013 Share Posted June 30, 2013 I want in my registration process the date of birth field should be mandatory as well as it will validate with current date how can i perform it please help. Link to comment Share on other sites More sharing options...
vekia Posted June 30, 2013 Share Posted June 30, 2013 if you want to set up birthday as a required field, go to the classes/Customer.php file you've got there object definition with all fields, there is birthday field definition: 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), add to this required=>true param Link to comment Share on other sites More sharing options...
tsandeep Posted July 16, 2013 Author Share Posted July 16, 2013 vekia thanxxx alot Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 you're welcome i marked this thread as [solved] if you've got any other questions - feel free to continue discussion here regards Link to comment Share on other sites More sharing options...
luckin315 Posted September 3, 2013 Share Posted September 3, 2013 I have still problem with birthday required. I edit Customer.php and add required=>true. The field is now required but when i select date of birth on the page with authentification, system give me error "Birthday is required" and I can't save it. I use prestashop 1.5.4.1. Thanks for reply Customer.php - 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true) Link to comment Share on other sites More sharing options...
vekia Posted September 3, 2013 Share Posted September 3, 2013 and if you remove required => true you've got still the same? Link to comment Share on other sites More sharing options...
luckin315 Posted September 4, 2013 Share Posted September 4, 2013 (edited) no there is no problem without required. I try new installation 1.5.4.1 and there is same problem. In identity.tpl is birthday too and works good with birthday required. Edited September 4, 2013 by luckin315 (see edit history) Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 14, 2013 Share Posted October 14, 2013 Same problem with version 1.5.6.0 Any Help. Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 what kind of problem you've got ? this one: I want in my registration process the date of birth field should be mandatory as well as it will validate with current date how can i perform it please help. ? Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 15, 2013 Share Posted October 15, 2013 Same quote again Customer.php - 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true) This does not work. Even if birth day entered errors as birthday required Link to comment Share on other sites More sharing options...
vekia Posted October 15, 2013 Share Posted October 15, 2013 weird, i tested it on my demo store (1.5.6.0) and everything works well then. what theme you use? default one? Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 15, 2013 Share Posted October 15, 2013 yes the default one Link to comment Share on other sites More sharing options...
love-vaping Posted October 16, 2013 Share Posted October 16, 2013 usign v1.5.4.1 and having the same problem. Using the below: 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true param ), This leaves my page not loading... Any suggestions would be much appreciated! Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 16, 2013 Share Posted October 16, 2013 Hi love-vaping It is not 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true param ), Instead it is 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true), regards Amod Link to comment Share on other sites More sharing options...
vekia Posted October 16, 2013 Share Posted October 16, 2013 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true param ), true param - this is wrong! you have to use "true" only Link to comment Share on other sites More sharing options...
love-vaping Posted October 17, 2013 Share Posted October 17, 2013 Thank you for that update! Was a silly mistake really.... But, having made that change it is not possible to register as a new customer, as it always states birthday required, even when it has been entered... Link to comment Share on other sites More sharing options...
vekia Posted October 17, 2013 Share Posted October 17, 2013 yes, you've got the same issue as other merchants here i don't know where the problem is i will inspect authentication controller, maybe i will find solution for this weridy issue Link to comment Share on other sites More sharing options...
amodkarmarkar Posted October 17, 2013 Share Posted October 17, 2013 (edited) Some how i solved this issue by removing the above parameters that is This 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'required' => true param ), to This 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate' ), Again I mean to default and Made changes in classes/validate.php As This public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return true; to This public static function isBirthDate($date) { if (empty($date) || $date == '0000-00-00') return false; This atlest gave an error as invalid date of birth but only when you fill all the required fields Hope so i have explained you better, Might be helpfull to you. Regards Amod Edited October 17, 2013 by amodkarmarkar (see edit history) 1 Link to comment Share on other sites More sharing options...
BuckWierd Posted November 17, 2013 Share Posted November 17, 2013 (edited) The version from amodkarmarkar worked for me!!!THANKS A LOT!!!!!using Prestashop 1.5.6.0 Another question...Is it possible now to add the red "*" to the Birthday field? Edited November 17, 2013 by BuckWierd (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 17, 2013 Share Posted November 17, 2013 The version from amodkarmarkar worked for me!!! THANKS A LOT!!!!! using Prestashop 1.5.6.0 Another question... Is it possible now to add the red "*" to the Birthday field? you can do it in authentication.tpl file located in your theme directory (themes/YOUR_THEME/authentication.tpl) <sup>*</sup> Link to comment Share on other sites More sharing options...
BuckWierd Posted November 17, 2013 Share Posted November 17, 2013 I tried that, but I can't find the right place for it...Where do I have to place the <sup>*</sup> ? <p class="select"> <span>{l s='Date of Birth'}</span> <select id="days" name="days"> <option value="">-</option> {foreach from=$days item=day} <option value="{$day}" {if ($sl_day == $day)} selected="selected"{/if}>{$day} </option> {/foreach} </select> Link to comment Share on other sites More sharing options...
vekia Posted November 17, 2013 Share Posted November 17, 2013 here: <p class="select"> <span>{l s='Date of Birth'} <sup>*</sup></span> <select id="days" name="days"> <option value="">-</option> {foreach from=$days item=day} <option value="{$day}" {if ($sl_day == $day)} selected="selected"{/if}>{$day} </option> {/foreach} </select> Link to comment Share on other sites More sharing options...
BuckWierd Posted November 17, 2013 Share Posted November 17, 2013 I tried that before and it doesn't work Birthday is still without the "*" Link to comment Share on other sites More sharing options...
aarticianpc Posted March 1, 2014 Share Posted March 1, 2014 Hello Everyone, I have found root cause of the date of birthday required error. Here is complete flow of action. function processSubmitAccount() in AuthController which is taking care of post data and validate them. Then If we marked birthday field as required field then we need to update ObjectModel.php file. Because validation is checked based on parameters set in classes\Customer.php file and in Customer.php file there is birthday field on which are setting validation required=>true but there is no such fields in authentication.tpl file and in ObjectModel.php file there is function called validateController() which is checking for each required field data and produces error array. So we have to update it for birthday field. In validateController() function you can find below code: if (isset($data['required']) && $data['required'] && empty($value) && $value !== '0') { if (!$this->id || $field != 'passwd') $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); } Replace it with below code: if(isset($data['required']) && $data['required'] && $field == 'birthday') { if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); } } elseif (isset($data['required']) && $data['required'] && empty($value) && $value !== '0') { if (!$this->id || $field != 'passwd') $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); } Let me know if it works or not. I have checked with all the conditions and it works well. 1 Link to comment Share on other sites More sharing options...
B@JTík Posted June 2, 2014 Share Posted June 2, 2014 Hello Everyone, I have found root cause of the date of birthday required error. Thanks a lot, very helpful. Adapted code for Presta 1.6: if(isset($data['required']) && $data['required'] && $field == 'birthday') { if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '-' && Tools::getValue('days') == '-' && Tools::getValue('years') == '-')) { $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); } } elseif (isset($data['required']) && $data['required'] && empty($value) && $value !== '0') { if (!$this->id || $field != 'passwd') { $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); } } 1 Link to comment Share on other sites More sharing options...
miguelhtc19 Posted June 6, 2014 Share Posted June 6, 2014 hi all could help me please, I can not make the date of birth is required, and looked everywhere and I can not how, use PS 1.6 thanks Link to comment Share on other sites More sharing options...
vishalsingh119 Posted November 1, 2016 Share Posted November 1, 2016 you can do it in authentication.tpl file located in your theme directory (themes/YOUR_THEME/authentication.tpl) <sup>*</sup> hi vekia, its not working for me.i added the required true in validate file but after then also there have issue. when i select 31 feb then its showing birthday is required and birth date is invalid but if i select right date like 25feb then also it showing error birthday is required. Do you have nay solution for this. Link to comment Share on other sites More sharing options...
vishalsingh119 Posted November 1, 2016 Share Posted November 1, 2016 hi vekia, its not working for me.i added the required true in validate file but after then also there have issue. when i select 31 Feb then its showing birthday is required and birth date is invalid but if i select right date like 25 Feb then also it showing error birthday is required. Do you have nay solution for this. Link to comment Share on other sites More sharing options...
Recommended Posts