Jump to content

birthday required for checkout


Recommended Posts

  • 2 weeks later...
  • 1 month later...

There is a problem with ObjectModel.php -> validateController(...). 

When "Birthday" is set to 'required' => true, then validateController() checking field value "birthday" which does not exists, because in authentication form birthday is created from 3 fields (years, months, days).

 

Here is quick fix for that (version 1.5.3.1):

 

change code in ObjectModel.php -> validateController(..):

// Checking for required fields
			if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
				if (!$this->id || $field != 'passwd')
					$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); 

to this one:

// Checking for required fields
			if($field == 'birthday' && isset($data['required']) && $data['required']) 
			{
				$birthday = ((int)Tools::getValue('years')>0 && (int)Tools::getValue('months')>0 && (int)Tools::getValue('days')>0 ? (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days') : '');
				if(!Validate::isBirthDate($birthday))
					$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is incorrect.');
				else if(empty($birthday))
					$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
			} 
			else if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
			{
				if (!$this->id || $field != 'passwd')
					$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
			}
Edited by siaip (see edit history)
Link to comment
Share on other sites

  • 10 months later...
×
×
  • Create New...