From f4f802efe3cccd68f3a6b40eb8312bfd8e24d643 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Fri, 30 Mar 2007 12:34:53 +0000
Subject: Fixed #535

---
 .gitattributes                                     |  3 ++
 HISTORY                                            |  1 +
 .../Web/UI/ActiveControls/TActiveRadioButton.php   | 11 -------
 framework/Web/UI/WebControls/TRadioButton.php      | 10 ++++++
 .../tickets/protected/pages/Ticket535.page         | 15 +++++++++
 .../tickets/protected/pages/Ticket535.php          | 16 ++++++++++
 .../tickets/tests/Ticket535TestCase.php            | 36 ++++++++++++++++++++++
 7 files changed, 81 insertions(+), 11 deletions(-)
 create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket535.page
 create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket535.php
 create mode 100644 tests/FunctionalTests/tickets/tests/Ticket535TestCase.php

diff --git a/.gitattributes b/.gitattributes
index af43113d..10cefb88 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2412,6 +2412,8 @@ tests/FunctionalTests/tickets/protected/pages/Ticket526.page -text
 tests/FunctionalTests/tickets/protected/pages/Ticket526.php -text
 tests/FunctionalTests/tickets/protected/pages/Ticket528.page -text
 tests/FunctionalTests/tickets/protected/pages/Ticket528.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket535.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket535.php -text
 tests/FunctionalTests/tickets/protected/pages/Ticket538.page -text
 tests/FunctionalTests/tickets/protected/pages/Ticket538.php -text
 tests/FunctionalTests/tickets/protected/pages/Ticket54.page -text
@@ -2452,6 +2454,7 @@ tests/FunctionalTests/tickets/tests/Ticket507TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket521TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket526TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket528TestCase.php -text
+tests/FunctionalTests/tickets/tests/Ticket535TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket538TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket54TestCase.php -text
 tests/FunctionalTests/tickets/tests/Ticket573TestCase.php -text
diff --git a/HISTORY b/HISTORY
index a980fcd1..0a191f45 100644
--- a/HISTORY
+++ b/HISTORY
@@ -6,6 +6,7 @@ BUG: Ticket#500 - URL encode in callback (Wei)
 BUG: Ticket#517 - Quickstart I18N sample: conflicting module ID (Wei)
 BUG: Ticket#521 - comment tag on TActiveButton stop callback (Wei)
 BUG: Ticket#526 - TDatePicker Mode="Button" with ActivePanel Enabled="false" (Wei)
+BUG: Ticket#535 - TRadioButton->GroupName bug on callback (Wei)
 BUG: Ticket#538 - TActiveListBox doesn't support optgroup (Wei)
 BUG: Ticket#549 - set/get Timestamp on TDatePicker shound handle "null" values (Qiang)
 BUG: Ticket#550 - explicitly include TCallbackClientSide in TCallbackOptions (Qiang)
diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButton.php b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
index 16a91688..504a52da 100644
--- a/framework/Web/UI/ActiveControls/TActiveRadioButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveRadioButton.php
@@ -109,17 +109,6 @@ class TActiveRadioButton extends TRadioButton implements IActiveControl, ICallba
 			$this->getPage()->getCallbackClient()->check($this, $value);
 	}
 
-	/**
-	 * Add the group name as post data loader if group name is set.
-	 */
-	protected function addToPostDataLoader()
-	{
-		parent::addToPostDataLoader();
-		$group = $this->getGroupName();
-		if(!empty($group))
-			$this->getPage()->registerPostDataLoader($group);
-	}
-
 	/**
 	 * Override parent implementation, no javascript is rendered here instead
 	 * the javascript required for active control is registered in {@link addAttributesToRender}.
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index d35372b3..bab03f88 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -155,6 +155,16 @@ class TRadioButton extends TCheckBox
 		$this->_uniqueGroupName=null;
 	}
 
+	/**
+	 * Add the group name as post data loader if group name is set.
+	 */
+	protected function addToPostDataLoader()
+	{
+		parent::addToPostDataLoader();
+		$group = $this->getGroupName();
+		if(!empty($group))
+			$this->getPage()->registerPostDataLoader($this->getUniqueGroupName());
+	}
 	/**
 	 * @return string the name used to fetch radiobutton post data
 	 */
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket535.page b/tests/FunctionalTests/tickets/protected/pages/Ticket535.page
new file mode 100644
index 00000000..4b9ba6fe
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket535.page
@@ -0,0 +1,15 @@
+<com:TContent ID="Content">
+
+<h2><strong>Without</strong> GroupName it is OK</h2>
+   <com:TRadioButton ID="radio1"  Text="Radio Button 1" /><br/>
+   <com:TRadioButton ID="radio2"  Text="Radio Button 1" /><br/>
+      <com:TActiveButton id="button1" OnCallback="noGroup" Text="test without GroupName" />
+<br/><br/>
+<h2>But with the same...</h2>
+   <com:TRadioButton ID="bad_radio1" GroupName="bad" Text="Bad Radio Button 1" /><br/>
+   <com:TRadioButton ID="bad_radio2" GroupName="bad" Text="Bad Radio Button 1" /><br/>
+      <com:TActiveButton id="button2" OnCallback="group" Text="test with a GroupName" />
+
+<com:TActiveLabel ID="label1" Text="Label 1"/>
+
+</com:TContent>
\ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket535.php b/tests/FunctionalTests/tickets/protected/pages/Ticket535.php
new file mode 100644
index 00000000..4f9b2f51
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket535.php
@@ -0,0 +1,16 @@
+<?php
+Prado::using('System.Web.UI.ActiveControls.*');
+class Ticket535 extends TPage
+{
+	public function noGroup($sender, $param)
+	{
+		$this->label1->Text = "radio1 checked:{".$this->radio1->getChecked()."}   radio2 checked:{".$this->radio2->getChecked()."} ";
+	}
+
+	public function group($sender, $param)
+	{
+		$this->label1->Text = "bad_radio1 checked:{".$this->bad_radio1->getChecked()."}   bad_radio2 checked:{".$this->bad_radio2->getChecked()."} ";
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php
new file mode 100644
index 00000000..26f70803
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php
@@ -0,0 +1,36 @@
+<?php
+
+class Ticket535TestCase extends SeleniumTestCase
+{
+	function test()
+	{
+		$base = 'ctl0_Content_';
+		$this->open('tickets/index.php?page=Ticket535');
+		$this->assertTitle("Verifying Ticket 535");
+
+		$this->assertText("{$base}label1", "Label 1");
+
+		$this->click("{$base}radio1");
+		$this->click("{$base}button1");
+		$this->pause(800);
+		$this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{}');
+
+		$this->click("{$base}radio2");
+		$this->click("{$base}button1");
+		$this->pause(800);
+		$this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{1}');
+
+		$this->click("{$base}bad_radio1");
+		$this->click("{$base}button2");
+		$this->pause(800);
+		$this->assertText("{$base}label1", 'bad_radio1 checked:{1} bad_radio2 checked:{}');
+
+		$this->click("{$base}bad_radio2");
+		$this->click("{$base}button2");
+		$this->pause(800);
+		$this->assertText("{$base}label1", 'bad_radio1 checked:{} bad_radio2 checked:{1}');
+	}
+
+}
+
+?>
\ No newline at end of file
-- 
cgit v1.2.3