diff --git a/class/xoopsform/formtext.php b/class/xoopsform/formtext.php index 3f771d93b..9590e651f 100644 --- a/class/xoopsform/formtext.php +++ b/class/xoopsform/formtext.php @@ -45,10 +45,13 @@ class XoopsFormText extends icms_form_elements_Text * @param int $size Size * @param int $maxlength Maximum length of text * @param string $value Initial text + * @param bool $autocomplete Whether to use autocomplete functionality in browser. Seems to have no effect in render method. + * @param mixed $number Whether to treat it as a number when rendering (essentially boolean, but could be 1/0) + */ - function __construct($caption, $name, $size, $maxlength, $value = '', $autocomplete = false) + function __construct($caption, $name, $size, $maxlength, $value = '', $autocomplete = false, $number = false) { - parent::__construct($caption, $name, $size, $maxlength, $value, $autocomplete); + parent::__construct($caption, $name, $size, $maxlength, $value, $autocomplete, $number); $this->_deprecated = icms_core_Debug::setDeprecated('icms_form_elements_Text', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); } } diff --git a/libraries/icms/form/elements/Text.php b/libraries/icms/form/elements/Text.php index 3356565ea..f1b3ffd63 100644 --- a/libraries/icms/form/elements/Text.php +++ b/libraries/icms/form/elements/Text.php @@ -45,6 +45,12 @@ class icms_form_elements_Text extends icms_form_Element { */ public $autocomplete = false; + /** + * Treat it as a number or text field when rendering. + * @var boolean + */ + public $numberOrText = false; + /** * Constructor * @@ -53,14 +59,17 @@ class icms_form_elements_Text extends icms_form_Element { * @param int $size Size * @param int $maxlength Maximum length of text * @param string $value Initial text + * @param bool $autocomplete Whether to use autocomplete functionality in browser. Seems to have no effect in render method. + * @param mixed $number Whether to treat it as a number-only box (essentially a boolean, but 1/0 might be passed in) */ - public function __construct($caption, $name, $size, $maxlength, $value = '', $autocomplete = false) { + public function __construct($caption, $name, $size, $maxlength, $value = '', $autocomplete = false, $number = false) { $this->setCaption($caption); $this->setName($name); $this->_size = (int) $size; $this->_maxlength = (int) $maxlength; $this->setValue($value); - $this->autoComplete = !empty($autocomplete); + $this->autocomplete = !empty($autocomplete); + $this->numberOrText = ($number ? 'number' : 'text'); } /** @@ -81,6 +90,15 @@ public function getMaxlength() { return $this->_maxlength; } + /** + * Get numbers or text + * + * @return int + */ + public function getNumberOrText() { + return $this->numberOrText; + } + /** * Get initial content * @@ -106,7 +124,8 @@ public function setValue($value) { * @return string HTML */ public function render() { - return "