Add Number functionality to Icinga\Form\SendCommand
This commit is contained in:
parent
f102f75eb9
commit
56b8b398c2
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to generate a number input
|
||||||
|
*/
|
||||||
|
class Zend_View_Helper_FormNumber extends \Zend_View_Helper_FormText
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generates a html number input
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @param string $name The element name.
|
||||||
|
* @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)
|
||||||
|
{
|
||||||
|
return '<input type="number"'
|
||||||
|
. ' name="' . $this->view->escape($name) . '"'
|
||||||
|
. ' value="' . $this->view->escape($value) . '"'
|
||||||
|
. ' id="' . $this->view->escape($name) . '"'
|
||||||
|
. $this->_htmlAttribs($attribs)
|
||||||
|
. $this->getClosingBracket();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -3,6 +3,8 @@ namespace Icinga\Form\Elements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date form element
|
* Date form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
*/
|
*/
|
||||||
class Date extends \Zend_Form_Element_Xhtml
|
class Date extends \Zend_Form_Element_Xhtml
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
namespace Icinga\Form\Elements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
|
*/
|
||||||
|
class Number extends \Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default form view helper to use for rendering
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = "formNumber";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -3,6 +3,8 @@ namespace Icinga\Form\Elements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time form element
|
* Time form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
*/
|
*/
|
||||||
class Time extends \Zend_Form_Element_Xhtml
|
class Time extends \Zend_Form_Element_Xhtml
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Form;
|
||||||
use Icinga\Form\Builder;
|
use Icinga\Form\Builder;
|
||||||
use Icinga\Form\Elements\Date;
|
use Icinga\Form\Elements\Date;
|
||||||
use Icinga\Form\Elements\Time;
|
use Icinga\Form\Elements\Time;
|
||||||
|
use Icinga\Form\Elements\Number;
|
||||||
|
|
||||||
class SendCommand extends Builder
|
class SendCommand extends Builder
|
||||||
{
|
{
|
||||||
|
@ -125,6 +126,27 @@ class SendCommand extends Builder
|
||||||
{
|
{
|
||||||
return $this->getElement($id)->options[$_POST[$id]];
|
return $this->getElement($id)->options[$_POST[$id]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @TODO: "min", "max" and "step" seem to have no effect :(
|
||||||
|
*/
|
||||||
|
public function addNumberBox($id, $label, $value = "", $min = 0, $max = -1, $step = "any")
|
||||||
|
{
|
||||||
|
$number = new Number($id);
|
||||||
|
$number->setValue($value);
|
||||||
|
$this->addElement($number, $id, array(
|
||||||
|
'label' => $label,
|
||||||
|
'step' => $step,
|
||||||
|
'min' => $min,
|
||||||
|
'max' => $max
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNumber($id)
|
||||||
|
{
|
||||||
|
return $this->getValue($id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue