|
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
|
|
|
* RadioYesNo - Yes/No radio buttons. |
|
16
|
|
|
* |
|
17
|
|
|
* A pair of radio buttons labelled YES and NO with values 1 and 0 |
|
18
|
|
|
* |
|
19
|
|
|
* @category Xoops\Form\RadioYesNo |
|
20
|
|
|
* @package Xoops\Form |
|
21
|
|
|
* @author Kazumi Ono <[email protected]> |
|
22
|
|
|
* @copyright 2001-2015 XOOPS Project (http://xoops.org) |
|
23
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
24
|
|
|
* @link http://xoops.org |
|
25
|
|
|
*/ |
|
26
|
|
|
class RadioYesNo extends Radio |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Constructor |
|
30
|
|
|
* |
|
31
|
|
|
* @param string|array $caption Caption or array of all attributes |
|
32
|
|
|
* Control attributes: |
|
33
|
|
|
* :yes label for '1' response |
|
34
|
|
|
* :no label for '0' response |
|
35
|
|
|
* @param string $name element name |
|
36
|
|
|
* @param string|null $value Pre-selected value, can be "0" (No) or "1" (Yes) |
|
37
|
|
|
* @param string $yes String for "Yes" |
|
38
|
|
|
* @param string $no String for "No" |
|
39
|
|
|
*/ |
|
40
|
3 |
|
public function __construct($caption, $name = null, $value = null, $yes = \XoopsLocale::YES, $no = \XoopsLocale::NO) |
|
41
|
|
|
{ |
|
42
|
3 |
|
parent::__construct($caption, $name, $value, true); |
|
43
|
3 |
|
if (is_array($caption)) { |
|
44
|
|
|
$this->set(':inline'); |
|
45
|
|
|
$this->setIfNotSet(':yes', \XoopsLocale::YES); |
|
46
|
|
|
$this->setIfNotSet(':no', \XoopsLocale::NO); |
|
47
|
|
|
} else { |
|
48
|
3 |
|
$this->setWithDefaults(':yes', $yes, \XoopsLocale::YES); |
|
49
|
3 |
|
$this->setWithDefaults(':no', $no, \XoopsLocale::NO); |
|
50
|
|
|
} |
|
51
|
3 |
|
$this->addOptionArray([1 => $this->get(':yes'), 0 => $this->get(':no')]); |
|
52
|
3 |
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|