summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--UPGRADE3
-rw-r--r--demos/quickstart/protected/pages/Controls/List.page10
-rw-r--r--framework/Web/UI/WebControls/TListControl.php3
-rw-r--r--tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php4
-rw-r--r--tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php2
-rw-r--r--tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php2
-rw-r--r--tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php4
8 files changed, 14 insertions, 16 deletions
diff --git a/HISTORY b/HISTORY
index 8d764697..477534d4 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2,6 +2,8 @@ Version 3.0RC2 April 16, 2006
=============================
BUG: Ticket#118 - Variables that may not have been initialized (Qiang)
CHG: Moved localize() into PradoBase (Qiang)
+CHG: List controls now use array keys as list item values even if
+ the array is integer-indexed (Qiang)
ENH: Optimized the representation and evaluation of template expressions (Qiang)
Version 3.0RC1 April 5, 2006
diff --git a/UPGRADE b/UPGRADE
index 391c55ff..b7bbd35b 100644
--- a/UPGRADE
+++ b/UPGRADE
@@ -19,6 +19,9 @@ Upgrading from v3.0.0 RC1
- !!! The context of template expression/statements/databinding tags
is changed to the control owning the template. Previously, it was
the control representing the tag.
+- !!! List controls databound with integer-indexed arrays will have
+ the integers as their list item values. Previously, it used the array
+ values as the list item values.
Upgrading from v3.0.0 beta
--------------------------
diff --git a/demos/quickstart/protected/pages/Controls/List.page b/demos/quickstart/protected/pages/Controls/List.page
index e3a6f368..cac07330 100644
--- a/demos/quickstart/protected/pages/Controls/List.page
+++ b/demos/quickstart/protected/pages/Controls/List.page
@@ -23,16 +23,10 @@ List controls covered in this section all inherit directly or indirectly from <t
</ul>
<p>
-Since <tt>TListControl</tt> inherits from <tt>TDataBoundControl</tt>, these list controls also share a common operation known as <tt>databinding</tt>. The <tt>Items</tt> can be populated from preexisting data specified by <tt>DataSource</tt> or <tt>DataSourceID</tt>. A function call to <tt>dataBind()</tt> will cause the data population. For list controls, data can be specified in three kinds of format:
+Since <tt>TListControl</tt> inherits from <tt>TDataBoundControl</tt>, these list controls also share a common operation known as <tt>databinding</tt>. The <tt>Items</tt> can be populated from preexisting data specified by <tt>DataSource</tt> or <tt>DataSourceID</tt>. A function call to <tt>dataBind()</tt> will cause the data population. For list controls, data can be specified in the following two kinds of format:
</p>
<ul>
- <li>integer-indexed array, <tt>TList</tt> or traversable : each array element value will be used as the value and text for a list item. For example
-<com:TTextHighlighter CssClass="source">
-$listbox->DataSource=array('item 1','item 2','item 3');
-$listbox->dataBind();
-</com:TTextHighlighter>
- </li>
- <li>associative array, <tt>TMap</tt> or traversable : array keys will be used as list item values, and array values will be used as list item texts. For example
+ <li>one-dimensional array or objects implementing <tt>ITraversable</tt> : array keys will be used as list item values, and array values will be used as list item texts. For example
<com:TTextHighlighter CssClass="source">
$listbox->DataSource=array(
'key 1'=>'item 1',
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index ccbce4d6..37c232e6 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -190,8 +190,7 @@ abstract class TListControl extends TDataBoundControl
else
{
$text=$object;
- if(is_string($key))
- $item->setValue($key);
+ $item->setValue("$key");
}
$item->setText($textFormat===''?$text:sprintf($textFormat,$text));
$items->add($item);
diff --git a/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php b/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php
index a845402d..50f2545a 100644
--- a/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php
+++ b/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php
@@ -29,8 +29,8 @@ class CheckBoxListTestCase extends SeleniumTestCase
$this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", "");
// Databind to an integer-indexed array
- $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList1\$1' and @value='item 2']", "");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: item 2, Text: item 2)", "");
+ $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList1\$1' and @value='1']", "");
+ $this->verifyTextPresent("Your selection is: (Index: 1, Value: 1, Text: item 2)", "");
// Databind to an associative array:
$this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList2\$1' and @value='key 2']", "");
diff --git a/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php b/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php
index cfb2047b..4c66236e 100644
--- a/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php
+++ b/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php
@@ -35,7 +35,7 @@ class DropDownListTestCase extends SeleniumTestCase
// Databind to an integer-indexed array
$this->selectAndWait("ctl0\$body\$DBDropDownList1", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: item 3, Text: item 3)", "");
+ $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", "");
// Databind to an associative array
$this->selectAndWait("ctl0\$body\$DBDropDownList2", "label=item 2");
diff --git a/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php b/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php
index 9862d1d1..c031c5fd 100644
--- a/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php
+++ b/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php
@@ -52,7 +52,7 @@ class ListBoxTestCase extends SeleniumTestCase
// Databind to an integer-indexed array
$this->selectAndWait("ctl0\$body\$DBListBox1[]", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: item 3, Text: item 3)", "");
+ $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", "");
// Databind to an associative array
$this->selectAndWait("ctl0\$body\$DBListBox2[]", "label=item 2");
diff --git a/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php b/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php
index 04ac376c..82cae1bf 100644
--- a/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php
+++ b/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php
@@ -29,8 +29,8 @@ class RadioButtonListTestCase extends SeleniumTestCase
$this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", "");
// Databind to an integer-indexed array
- $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList1' and @value='item 1']", "");
- $this->verifyTextPresent("Your selection is: (Index: 0, Value: item 1, Text: item 1)", "");
+ $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList1' and @value='0']", "");
+ $this->verifyTextPresent("Your selection is: (Index: 0, Value: 0, Text: item 1)", "");
// Databind to an associative array:
$this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList2' and @value='key 2']", "");