XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
formradio.php
1<?php
13
14if (!defined('XOOPS_ROOT_PATH')) {
15 exit();
16}
17
18class XoopsFormRadio extends XoopsFormElement
19{
20
26 public $_options = [];
27
33 public $_value = null;
34
42 public function __construct($caption, $name, $value = null)
43 {
44 $this->setCaption($caption);
45 $this->setName($name);
46 if (isset($value)) {
47 $this->setValue($value);
48 }
49 }
50 public function XoopsFormRadio($caption, $name, $value = null)
51 {
52 return self::__construct($caption, $name, $value);
53 }
54
60 public function getValue()
61 {
62 return $this->_value;
63 }
64
70 public function setValue($value)
71 {
72 $this->_value = $value;
73 }
74
81 public function addOption($value, $name= '')
82 {
83 if ('' != $name) {
84 $this->_options[$value] = $name;
85 } else {
86 $this->_options[$value] = $value;
87 }
88 }
89
95 public function addOptionArray($options)
96 {
97 if (is_array($options)) {
98 foreach ($options as $k=>$v) {
99 $this->addOption($k, $v);
100 }
101 }
102 }
103
109 public function getOptions()
110 {
111 return $this->_options;
112 }
113
119 public function render()
120 {
121 $root =& XCube_Root::getSingleton();
122 $renderSystem =& $root->getRenderSystem(XOOPSFORM_DEPENDENCE_RENDER_SYSTEM);
123
124 $renderTarget =& $renderSystem->createRenderTarget();
125
126 $renderTarget->setAttribute('legacy_module', 'legacy');
127 $renderTarget->setTemplateName('legacy_xoopsform_radio.html');
128 $renderTarget->setAttribute('element', $this);
129
130 $renderSystem->render($renderTarget);
131
132 return $renderTarget->getResult();
133 }
134}
setCaption($caption)
addOption($value, $name='')
Definition formradio.php:81
addOptionArray($options)
Definition formradio.php:95
setValue($value)
Definition formradio.php:70
__construct($caption, $name, $value=null)
Definition formradio.php:42