Skip to content

Commit

Permalink
lib: Respect the disabled attribute in `FormNumber'
Browse files Browse the repository at this point in the history
refs #5525
  • Loading branch information
lippserd committed Sep 2, 2014
1 parent 5485ca8 commit c7a4098
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions application/views/helpers/FormNumber.php
Expand Up @@ -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 '<input type="number"'
. ' name="' . $this->view->escape($name) . '"'
. ' value="' . $this->view->escape($value) . '"'
. ' id="' . $this->view->escape($name) . '"'
. $this->_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(
'<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;
}
}

0 comments on commit c7a4098

Please sign in to comment.