_format = $format; return $this; } /** * @return string */ public function getFormat() { return $this->_format; } public function setView(Zend_View_Interface $view = null) { $this->_view = $view; return $this; } public function isValid($value, $context = null) { $attributes = $this->getAttribs(); $checkValue = $value; if (is_array($value)) { if (!isset($attributes['showYear']) || $attributes['showYear']) { $checkValueYear = Qs_Array::get($value, 'year'); } else { $checkValueYear = '0'; } if (!isset($attributes['showMonth']) || $attributes['showMonth']) { $checkValueMonth = Qs_Array::get($value, 'month'); } else { $checkValueMonth = '01'; } if (!isset($attributes['showDay']) || $attributes['showDay']) { $checkValueDay = $value['day']; } else { $checkValueDay = '01'; } if (ctype_digit($checkValueYear) && ctype_digit($checkValueMonth) && ctype_digit($checkValueDay)) { $checkValue = $checkValueYear . '-' . $checkValueMonth . '-' . $checkValueDay; } elseif ((!isset($attributes['showYear']) || $attributes['showYear']) && ctype_digit($checkValueYear)) { $checkValue = $checkValueYear; } else { $checkValue = null; } } return parent::isValid($checkValue, $context); } public function getValue() { if (!empty($this->_value)) { $value = '--'; if (is_array($this->_value)) { if (empty($this->_value['day'])) { $this->_value['day'] = 1; } $value = $this->_value['year'] . '-' . $this->_value['month'] . '-' . $this->_value['day']; } elseif (is_string($this->_value)) { $value = date($this->getFormat(), strtotime($this->_value)); } if ($value == '--') { $value = null; } $this->setValue($value); } return parent::getValue(); } }