summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TRadioButton.php
diff options
context:
space:
mode:
authorxue <>2006-07-29 14:43:53 +0000
committerxue <>2006-07-29 14:43:53 +0000
commite0c9de073cce5b5c9975694c03e2dbe63788bd66 (patch)
tree0c04506594635064d9f3f62eb45c8aad5c3be685 /framework/Web/UI/WebControls/TRadioButton.php
parent6385105e7793509de726b2941d038840c04195c1 (diff)
Merge from 3.0 branch till 1305.
Diffstat (limited to 'framework/Web/UI/WebControls/TRadioButton.php')
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php84
1 files changed, 57 insertions, 27 deletions
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index 244244cb..9b6786aa 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -68,6 +68,10 @@ class TRadioButton extends TCheckBox
*/
private $_globalID;
/**
+ * @var string previous UniqueID (used to calculate UniqueGroup)
+ */
+ private $_previousUniqueID=null;
+ /**
* @var string the name used to fetch radiobutton post data
*/
private $_uniqueGroupName=null;
@@ -140,12 +144,64 @@ class TRadioButton extends TCheckBox
}
/**
- * Sets the name of the group that the radio button belongs to
+ * Sets the name of the group that the radio button belongs to.
+ * The group is unique among the control's naming container.
* @param string the group name
+ * @see setUniqueGroupName
*/
public function setGroupName($value)
{
$this->setViewState('GroupName',$value,'');
+ $this->_uniqueGroupName=null;
+ }
+
+ /**
+ * @return string the name used to fetch radiobutton post data
+ */
+ public function getUniqueGroupName()
+ {
+ if(($groupName=$this->getViewState('UniqueGroupName',''))!=='')
+ return $groupName;
+ else if(($uniqueID=$this->getUniqueID())!==$this->_previousUniqueID || $this->_uniqueGroupName===null)
+ {
+ $groupName=$this->getGroupName();
+ $this->_previousUniqueID=$uniqueID;
+ if($uniqueID!=='')
+ {
+ if(($pos=strrpos($uniqueID,TControl::ID_SEPARATOR))!==false)
+ {
+ if($groupName!=='')
+ $groupName=substr($uniqueID,0,$pos+1).$groupName;
+ else if($this->getNamingContainer() instanceof TRadioButtonList)
+ $groupName=substr($uniqueID,0,$pos);
+ }
+ if($groupName==='')
+ $groupName=$uniqueID;
+ }
+ $this->_uniqueGroupName=$groupName;
+ }
+ return $this->_uniqueGroupName;
+ }
+
+ /**
+ * Sets the unique group name that the radio button belongs to.
+ * A unique group is a radiobutton group unique among the whole page hierarchy,
+ * while the {@link setGroupName GroupName} specifies a group that is unique
+ * among the control's naming container only.
+ * For example, each cell of a {@link TDataGrid} is a naming container.
+ * If you specify {@link setGroupName GroupName} for a radiobutton in a cell,
+ * it groups together radiobutton within a cell, but not the other, even though
+ * they have the same {@link setGroupName GroupName}.
+ * On the contratry, if {@link setUniqueGroupName UniqueGroupName} is used instead,
+ * it will group all appropriate radio buttons on the whole page hierarchy.
+ * Note, when both {@link setUniqueGroupName UniqueGroupName} and
+ * {@link setGroupName GroupName}, the former takes precedence.
+ * @param string the group name
+ * @see setGroupName
+ */
+ public function setUniqueGroupName($value)
+ {
+ $this->setViewState('UniqueGroupName',$value,'');
}
/**
@@ -178,32 +234,6 @@ class TRadioButton extends TCheckBox
}
/**
- * @return string the name used to fetch radiobutton post data
- */
- private function getUniqueGroupName()
- {
- if($this->_uniqueGroupName===null)
- {
- $groupName=$this->getGroupName();
- $uniqueID=$this->getUniqueID();
- if($uniqueID!=='')
- {
- if(($pos=strrpos($uniqueID,TControl::ID_SEPARATOR))!==false)
- {
- if($groupName!=='')
- $groupName=substr($uniqueID,0,$pos+1).$groupName;
- else if($this->getNamingContainer() instanceof TRadioButtonList)
- $groupName=substr($uniqueID,0,$pos);
- }
- if($groupName==='')
- $groupName=$uniqueID;
- }
- $this->_uniqueGroupName=$groupName;
- }
- return $this->_uniqueGroupName;
- }
-
- /**
* Renders a radiobutton input element.
* @param THtmlWriter the writer for the rendering purpose
* @param string checkbox id