blob: 2f12369bdadea035e0f3ceaf560b9347a40873fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<?php
/**
* TRadioButtonList class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
*/
/**
* TRadioButtonList class
*
* TRadioButtonList displays a list of radiobuttons on a Web page.
*
* TRadioButtonList inherits all properties and events of {@link TCheckBoxList}.
* Each TRadioButtonList displays one group of radiobuttons, i.e., at most
* one radiobutton can be selected at a time.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
* @since 3.0
*/
class TRadioButtonList extends TCheckBoxList
{
/**
* @return boolean whether this control supports multiple selection. Always false for radiobutton list.
*/
protected function getIsMultiSelect()
{
return false;
}
/**
* Creates a control used for repetition (used as a template).
* @return TControl the control to be repeated
*/
protected function createRepeatedControl()
{
return new TRadioButton;
}
/**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
* @param array the input data collection
* @return boolean whether the data of the control has been changed
*/
public function loadPostData($key,$values)
{
$value=isset($values[$key])?$values[$key]:'';
$oldSelection=$this->getSelectedIndex();
$this->ensureDataBound();
foreach($this->getItems() as $index=>$item)
{
if($item->getEnabled() && $item->getValue()===$value)
{
if($index===$oldSelection)
return false;
else
{
$this->setSelectedIndex($index);
return true;
}
}
}
return false;
}
}
?>
|