lib: Respect the disabled attribute in `FormNumber'

refs #5525
This commit is contained in:
Eric Lippmann 2014-09-02 16:53:33 +02:00
parent 5485ca8a25
commit c7a4098c04

View File

@ -2,29 +2,41 @@
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Zend_View_Helper_FormElement;
/** /**
* Helper to generate a number input * Render number input controls
*/ */
class Zend_View_Helper_FormNumber extends \Zend_View_Helper_FormText class Zend_View_Helper_FormNumber extends Zend_View_Helper_FormElement
{ {
/** /**
* Generates a html number input * Render the number input control
* *
* @access public * @param string $name
* @param int $value
* @param array $attribs
* *
* @param string $name The element name. * @return string The rendered number input control
* @param string $value The default value.
* @param array $attribs Attributes which should be added to the input tag.
*
* @return string The input tag and options XHTML.
*/ */
public function formNumber($name, $value = null, $attribs = null) public function formNumber($name, $value = null, $attribs = null)
{ {
return '<input type="number"' $info = $this->_getInfo($name, $value, $attribs);
. ' name="' . $this->view->escape($name) . '"' extract($info); // name, id, value, attribs, options, listsep, disable
. ' value="' . $this->view->escape($value) . '"' /** @var string $id */
. ' id="' . $this->view->escape($name) . '"' /** @var bool $disable */
. $this->_htmlAttribs($attribs) $disabled = '';
. $this->getClosingBracket(); if ($disable) {
$disabled = ' disabled="disabled"';
}
$html5 = sprintf(
'<input type="number" name="%s" id="%s" value="%s"%s%s%s',
$this->view->escape($name),
$this->view->escape($id),
$this->view->escape($value),
$disabled,
$this->_htmlAttribs($attribs),
$this->getClosingBracket()
);
return $html5;
} }
} }