value = $value['Year'] . '-' . $value['Month'] . '-' . $value['Day']; else if(is_array($value)&&(!$value['Day']||!$value['Month']||!$value['Year'])) $this->value = null; else if(is_string($value)) $this->value = $value; } function Field() { Requirements::javascript(SAPPHIRE_DIR . "/javascript/CalendarDateField.js"); $field = DateField::Field(); $id = $this->id(); $val = $this->attrValue(); if( preg_match( '/^\d{2}\/\d{2}\/\d{4}$/', $val ) ) { $dateArray = explode( '/', $val ); $val = $dateArray[2] . '-' . $dateArray[1] . '-' . $dateArray[0]; } $day = $month = $year = null; if($val) { $dateArray = explode( '-', $val ); $day = $dateArray[2]; $month = $dateArray[1]; $year = $dateArray[0]; } $fieldName = $this->name; return << / /
HTML; } function validate($validator) { if(Validator::get_javascript_validator_handler() == 'none') { return true; } if(!empty ($this->value) && !preg_match('/^([0-9][0-9]){1,2}\-[0-9]{1,2}\-[0-9]{1,2}$/', $this->value)) { $validator->validationError( $this->name, _t('DMYDateField.VALIDDATEFORMAT', "Please enter a valid date format (DD-MM-YYYY)."), "validation", false ); return false; } return true; } function jsValidation() { if(Validator::get_javascript_validator_handler() == 'none') { return ''; } $formID = $this->form->FormName(); $error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).'); $error = 'Please enter a valid date format (DD/MM/YYYY) from dmy.'; $jsFunc =<<