getSource(); foreach($source as $key => $value) { // convert the ID to an HTML safe value (dots are not replaced, as they are valid in an ID attribute) $itemID = $this->id() . '_' . preg_replace('/[^\.a-zA-Z0-9\-\_]/', '_', $key); if($key == $this->value) { $useValue = false; $checked = " checked=\"checked\""; } else { $checked = ""; } $odd = ($odd + 1) % 2; $extraClass = $odd ? "odd" : "even"; $extraClass .= " val" . preg_replace('/[^a-zA-Z0-9\-\_]/', '_', $key); $disabled = ($this->disabled || in_array($key, $this->disabledItems)) ? "disabled=\"disabled\"" : ""; $ATT_key = Convert::raw2att($key); $options .= "
  • name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" />
  • \n"; } // Add "custom" input field $value = ($this->value && !array_key_exists($this->value, $this->source)) ? $this->value : null; $checked = ($value) ? " checked=\"checked\"" : ''; $options .= "
  • " . sprintf("", $itemID, $this->name, $checked) . sprintf('', $itemID, _t('MemberDatetimeOptionsetField.Custom', 'Custom')) . sprintf("\n", $this->name, $value) . sprintf("", $this->Link() . '/validate'); $options .= ($value) ? sprintf( '(%s: "%s")', _t('MemberDatetimeOptionsetField.Preview', 'Preview'), Zend_Date::now()->toString($value) ) : ''; $options .= "" . _t('MemberDatetimeOptionsetField.TOGGLEHELP', 'Toggle formatting help') . ""; $options .= "
    "; $options .= $this->getFormattingHelpText(); $options .= "
    "; $options .= "
  • \n"; $id = $this->id(); return "\n"; } /** * @todo Put this text into a template? */ function getFormattingHelpText() { $output = ''; return $output; } function setValue($value) { if($value == '__custom__') { $value = isset($_REQUEST[$this->name . '_custom']) ? $_REQUEST[$this->name . '_custom'] : null; } if($value) { parent::setValue($value); } } function validate() { $value = isset($_POST[$this->name . '_custom']) ? $_POST[$this->name . '_custom'] : null; if(!$value) return true; // no custom value, don't validate // Check that the current date with the date format is valid or not $validator = $this->form ? $this->form->getValidator() : null; require_once 'Zend/Date.php'; $date = Zend_Date::now()->toString($value); $valid = Zend_Date::isDate($date, $value); if($valid) { return true; } else { if($validator) { $validator->validationError($this->name, _t('MemberDatetimeOptionsetField.DATEFORMATBAD',"Date format is invalid"), "validation", false); } return false; } } }