diff options
| -rw-r--r-- | HISTORY | 2 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TRadioButton.php | 71 | 
2 files changed, 32 insertions, 41 deletions
| @@ -6,7 +6,7 @@ BUG: Ticket#297 - THttpRequest::constructUrl() encoding bug about array GET para  BUG: TDataGrid may complain getting ItemType on a non-object if the grid is not data-bound (Qiang)  BUG: TCheckBox.Value should be converted to string (Qiang)  CHG: Ticket#206 - TBaseValidator.OnValidate is raised only when the validator is visible (Qiang) -ENH: Ticket#178 - Added TRadioButton.GlobalGroupName property (Qiang) +ENH: Ticket#178 - Added TRadioButton.UniqueGroupName property (Qiang)  ENH: Ticket#220 - TClientScripts method to import custom javascript files (Wei)  ENH: Ticket#225 - TRadioButton::getRadioButtonsInGroup() added (Wei)  ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName property (Wei) diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 74e908ca..c827fb64 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -147,7 +147,7 @@ class TRadioButton extends TCheckBox  	 * 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 setGlobalGroupName
 +	 * @see setUniqueGroupName
  	 */
  	public function setGroupName($value)
  	{
 @@ -156,33 +156,52 @@ class TRadioButton extends TCheckBox  	}
  	/**
 -	 * @return string the name of the global group that the radio button belongs to. Defaults to empty.
 +	 * @return string the name used to fetch radiobutton post data
  	 */
 -	public function getGlobalGroupName()
 +	public function getUniqueGroupName()
  	{
 -		return $this->getViewState('GlobalGroupName','');
 +		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 name of the global group that the radio button belongs to.
 -	 * A global group is a radiobutton group unique in the whole page hierarchy,
 +	 * 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.
 +	 * 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 setGlobalGroupName GlobalGroupName} is used instead,
 +	 * 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 setGlobalGroupName GlobalGroupName} and
 +	 * Note, when both {@link setUniqueGroupName UniqueGroupName} and
  	 * {@link setGroupName GroupName}, the former takes precedence.
  	 * @param string the group name
  	 * @see setGroupName
  	 */
 -	public function setGlobalGroupName($value)
 +	public function setUniqueGroupName($value)
  	{
 -		$this->setViewState('GlobalGroupName',$value,'');
 -		$this->_uniqueGroupName=null;
 +		$this->setViewState('UniqueGroupName',$value,'');
  	}
  	/**
 @@ -215,34 +234,6 @@ class TRadioButton extends TCheckBox  	}
  	/**
 -	 * @return string the name used to fetch radiobutton post data
 -	 */
 -	private function getUniqueGroupName()
 -	{
 -		if(($groupName=$this->getGlobalGroupName())!=='')
 -			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;
 -	}
 -
 -	/**
  	 * Renders a radiobutton input element.
  	 * @param THtmlWriter the writer for the rendering purpose
  	 * @param string checkbox id
 | 
