Remove unused attributes from the date time picker element

This commit is contained in:
Eric Lippmann 2017-07-04 10:32:30 +02:00
parent a5990d4de8
commit 53091384cd
2 changed files with 1 additions and 90 deletions

View File

@ -46,26 +46,14 @@ class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement
if (isset($attribs['placeholder']) && $attribs['placeholder'] instanceof DateTime) { if (isset($attribs['placeholder']) && $attribs['placeholder'] instanceof DateTime) {
$attribs['placeholder'] = $this->formatDate($attribs['placeholder'], $attribs['local']); $attribs['placeholder'] = $this->formatDate($attribs['placeholder'], $attribs['local']);
} }
$min = '';
if (! empty($attribs['min'])) {
$min = sprintf(' min="%s"', $this->formatDate($attribs['min'], $attribs['local']));
}
unset($attribs['min']); // Unset min to not render it again in $this->_htmlAttribs($attribs)
$max = '';
if (! empty($attribs['max'])) {
$max = sprintf(' max="%s"', $this->formatDate($attribs['max'], $attribs['local']));
}
unset($attribs['max']); // Unset max to not render it again in $this->_htmlAttribs($attribs)
$type = $attribs['local'] === true ? 'datetime-local' : 'datetime'; $type = $attribs['local'] === true ? 'datetime-local' : 'datetime';
unset($attribs['local']); // Unset local to not render it again in $this->_htmlAttribs($attribs) unset($attribs['local']); // Unset local to not render it again in $this->_htmlAttribs($attribs)
$html5 = sprintf( $html5 = sprintf(
'<input type="%s" name="%s" id="%s" step="1" value="%s"%s%s%s%s%s', '<input type="%s" name="%s" id="%s" step="1" value="%s"%s%s%s',
$type, $type,
$this->view->escape($name), $this->view->escape($name),
$this->view->escape($id), $this->view->escape($id),
$this->view->escape($value), $this->view->escape($value),
$min,
$max,
$disabled, $disabled,
$this->_htmlAttribs($attribs), $this->_htmlAttribs($attribs),
$this->getClosingBracket() $this->getClosingBracket()

View File

@ -24,20 +24,6 @@ class DateTimePicker extends FormElement
*/ */
protected $local = true; protected $local = true;
/**
* The expected lower bound for the elements value
*
* @var DateTime|null
*/
protected $min;
/**
* The expected upper bound for the elements
*
* @var DateTime|null
*/
protected $max;
/** /**
* (non-PHPDoc) * (non-PHPDoc)
* @see Zend_Form_Element::init() For the method documentation. * @see Zend_Form_Element::init() For the method documentation.
@ -48,69 +34,6 @@ class DateTimePicker extends FormElement
new DateTimeValidator($this->local), new DateTimeValidator($this->local),
true // true for breaking the validator chain on failure true // true for breaking the validator chain on failure
); );
if ($this->min !== null) {
$this->addValidator('GreaterThan', true, array('min' => $this->min));
}
if ($this->max !== null) {
$this->addValidator('LessThan', true, array('max' => $this->max));
}
}
public function setLocal($local)
{
$this->local = (bool) $local;
return $this;
}
public function getLocal()
{
return $this->local;
}
/**
* Set the expected lower bound for the elements value
*
* @param DateTime $min
*
* @return $this
*/
public function setMin(DateTime $min)
{
$this->min = $min;
return $this;
}
/**
* Get the expected lower bound for the elements value
*
* @return DateTime|null
*/
public function getMin()
{
return $this->min;
}
/**
* Set the expected upper bound for the elements value
*
* @param DateTime $max
*
* @return $this
*/
public function setMax(DateTime $max)
{
$this->max = $max;
return $this;
}
/**
* Get the expected upper bound for the elements value
*
* @return DateTime|null
*/
public function getMax()
{
return $this->max;
} }
/** /**