1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Form;
13:
14: /**
15: * Hidden - a hidden field
16: *
17: * @category Xoops\Form\Hidden
18: * @package Xoops\Form
19: * @author Kazumi Ono <onokazu@xoops.org>
20: * @copyright 2001-2015 XOOPS Project (http://xoops.org)
21: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22: * @link http://xoops.org
23: */
24: class Hidden extends Element
25: {
26:
27: /**
28: * Constructor
29: *
30: * @param string|array $name name attribute or array of all attributes
31: * @param string $value value attribute
32: */
33: public function __construct($name, $value = '')
34: {
35: if (is_array($name)) {
36: parent::__construct($name);
37: } else {
38: parent::__construct([]);
39: $this->set('caption', '');
40: $this->set('name', $name);
41: $this->set('value', $value);
42: }
43: $this->setHidden();
44: $this->set('type', 'hidden');
45: }
46:
47: /**
48: * render
49: *
50: * @return string rendered form element
51: */
52: public function render()
53: {
54: $attributes = $this->renderAttributeString();
55: return '<input ' . $attributes . 'value="'
56: . $this->getValue() . '" ' . $this->getExtra() .' >' . "\n";
57: }
58: }
59: