public function renderYear(DateField $field)
    {
        $fieldValue = $field->getValue();
        if (preg_match('/^\\d{2,}$/', $this->yearMin) > 0 && preg_match('/^\\d{2,}$/', $this->yearMax) > 0) {
            $yearHtml = '<select name="' . $field->getFormIdentifierAsString() . '[year]">
				<option value="">----</option>';
            for ($i = $this->yearMin; $i <= $this->yearMax; ++$i) {
                $selected = $i == $fieldValue['year'] ? ' selected' : null;
                $yearHtml .= '<option' . $selected . '>' . $i . '</option>';
            }
            $yearHtml .= '</select>';
        } else {
            $yearHtml = '<input type="text" size="4" name="' . $field->getFormIdentifierAsString() . '[year]" value="' . $fieldValue['year'] . '" class="form-date-year">';
        }
        return $yearHtml;
    }
예제 #2
0
 public function isValueEmpty()
 {
     if (parent::isValueEmpty() === true) {
         return true;
     }
     if (is_array($this->value) === true) {
         return !(isset($this->value['hour']) !== false && mb_strlen($this->value['hour']) > 0 || isset($this->value['min']) !== false && mb_strlen($this->value['min']) > 0 || isset($this->value['sec']) !== false && mb_strlen($this->value['sec']) > 0);
     }
     return false;
 }
 /**
  * @param DateField $field The field instance to render
  * @return string The rendered field
  */
 public function render(DateField $field)
 {
     if (is_array($field->getValue()) === true) {
         $field->setValue(null);
     }
     return '<input type="text" value="' . htmlspecialchars($field->getValue()) . '" name="' . $field->getFormIdentifierAsString() . '" id="' . $field->getName() . '"' . $this->getAttributesAsHtml() . '>';
 }