/**
  * This method creates an element to select the date of birth
  * @param string $fieldName The field name of the date of birth element
  */
 public static function getDateOfBirthElement($dayFieldName, $monthFieldName, $yearFieldName, $defaultDay = '', $defaultMonth = '', $defaultYear = '')
 {
     $days = array('none' => Customweb_I18n_Translation::__('Day'), '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31');
     $months = array('none' => Customweb_I18n_Translation::__('Month'), '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12');
     $years = array('none' => Customweb_I18n_Translation::__('Year'));
     $current = intval(date('Y'));
     for ($i = 0; $i < 130; $i++) {
         $years[$current] = $current;
         $current--;
     }
     $dayControl = new Customweb_Form_Control_Select($dayFieldName, $days, $defaultDay);
     $dayControl->addValidator(new Customweb_Form_Validator_NotEmpty($dayControl, Customweb_I18n_Translation::__("Please select the day on which you were born.")));
     $monthControl = new Customweb_Form_Control_Select($monthFieldName, $months, $defaultMonth);
     $monthControl->addValidator(new Customweb_Form_Validator_NotEmpty($monthControl, Customweb_I18n_Translation::__("Please select the month in which you were born.")));
     $yearControl = new Customweb_Form_Control_Select($yearFieldName, $years, $defaultYear);
     $yearControl->addValidator(new Customweb_Form_Validator_NotEmpty($yearControl, Customweb_I18n_Translation::__("Please select the year in which you were born.")));
     $yearControl->addValidator(new Customweb_Saferpay_Method_ValidateDateOfBirth($yearControl, 'dob-day', 'dob-month', 'dob-year'));
     $control = new Customweb_Form_Control_MultiControl('dayOfBirth', array($dayControl, $monthControl, $yearControl));
     $element = new Customweb_Form_Element(Customweb_I18n_Translation::__('Date of birth'), $control, Customweb_I18n_Translation::__('Select your date of birth.'));
     $element->setElementIntention(Customweb_Form_Intention_Factory::getDateOfBirthIntention());
     return $element;
 }
 /**
  * Constructor
  *
  * @param string $controlName Control Name
  * @param array $options A key / value map. Where the key is the submitted value and the value is the label of the option.
  * @param string $defaultValue The preselected option
  */
 public function __construct($controlName, $options, $defaultValue = '', $onChangeEvent = 'javascript:void(0)')
 {
     parent::__construct($controlName, $options, $defaultValue);
     $this->onChangeEvent = $onChangeEvent;
 }
 /**
  * This method creates the expiry year control.
  *
  * @return void
  */
 protected function createExpiryYearControl()
 {
     $defaultYear = $this->getSelectedExpiryYear();
     if (strlen($defaultYear) == 2 && $this->getExpiryYearNumberOfDigits() == 4) {
         // Add the leading year numbers in case it is only 2 chars long
         $defaultYear = '20' . $defaultYear;
     }
     $this->expiryYearControl = new Customweb_Form_Control_Select($this->getexpiryYearFieldName(), $this->getExpiryYearOptions(), $defaultYear);
     $this->expiryYearControl->addValidator(new Customweb_Form_Validator_NotEmpty($this->expiryYearControl, Customweb_I18n_Translation::__("Please select the expiry year on your card.")));
 }
 /**
  * Create an element to enter a date of birth.
  * 
  * @param string $yearFieldName
  * @param string $monthFieldName
  * @param string $dayFieldName
  * @param string $defaultYear
  * @param string $defaultMonth
  * @param string $defaultDay
  * @param string $errorMessage
  * @return Customweb_Form_Element
  */
 public static function getDateOfBirthElement($yearFieldName, $monthFieldName, $dayFieldName, $defaultYear = null, $defaultMonth = null, $defaultDay = null, $errorMessage = null, $startAge = 0)
 {
     $days = array('none' => Customweb_I18n_Translation::__('Day'));
     for ($i = 1; $i <= 31; $i++) {
         $days[($i < 10 ? '0' : '') . $i] = ($i < 10 ? '0' : '') . $i;
     }
     $dayControl = new Customweb_Form_Control_Select($dayFieldName, $days, $defaultDay);
     $dayControl->addValidator(new Customweb_Form_Validator_NotEmpty($dayControl, Customweb_I18n_Translation::__("Please select the day of your birth.")));
     $months = self::getMonthArray();
     $monthControl = new Customweb_Form_Control_Select($monthFieldName, $months, $defaultMonth);
     $monthControl->addValidator(new Customweb_Form_Validator_NotEmpty($monthControl, Customweb_I18n_Translation::__("Please select the month of your birth.")));
     $years = array('none' => Customweb_I18n_Translation::__('Year'));
     $current = intval(date('Y')) - $startAge;
     for ($i = 0; $i < 100; $i++) {
         $years[$current] = $current;
         $current--;
     }
     $yearControl = new Customweb_Form_Control_Select($yearFieldName, $years, $defaultYear);
     $yearControl->addValidator(new Customweb_Form_Validator_NotEmpty($yearControl, Customweb_I18n_Translation::__("Please select the the year of your birth.")));
     $control = new Customweb_Form_Control_MultiControl('date_of_birth', array($yearControl, $monthControl, $dayControl));
     $element = new Customweb_Form_Element(Customweb_I18n_Translation::__('Date of Birth'), $control, Customweb_I18n_Translation::__('Select the date of your birth.'));
     $element->setElementIntention(Customweb_Form_Intention_Factory::getDateOfBirthIntention())->setErrorMessage($errorMessage);
     return $element;
 }