From c7a4098c04103093c1db45a2e067bf966cd67e8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 2 Sep 2014 16:53:33 +0200 Subject: [PATCH] lib: Respect the disabled attribute in `FormNumber' refs #5525 --- application/views/helpers/FormNumber.php | 42 +++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/application/views/helpers/FormNumber.php b/application/views/helpers/FormNumber.php index a8768f0b71..1590d9b514 100644 --- a/application/views/helpers/FormNumber.php +++ b/application/views/helpers/FormNumber.php @@ -2,29 +2,41 @@ // {{{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 - * - * @access public + * Render the number input control * - * @param string $name The element name. - * @param string $value The default value. - * @param array $attribs Attributes which should be added to the input tag. + * @param string $name + * @param int $value + * @param array $attribs * - * @return string The input tag and options XHTML. + * @return string The rendered number input control */ public function formNumber($name, $value = null, $attribs = null) { - return '_htmlAttribs($attribs) - . $this->getClosingBracket(); + $info = $this->_getInfo($name, $value, $attribs); + extract($info); // name, id, value, attribs, options, listsep, disable + /** @var string $id */ + /** @var bool $disable */ + $disabled = ''; + if ($disable) { + $disabled = ' disabled="disabled"'; + } + $html5 = sprintf( + 'view->escape($name), + $this->view->escape($id), + $this->view->escape($value), + $disabled, + $this->_htmlAttribs($attribs), + $this->getClosingBracket() + ); + return $html5; } }