summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorxue <>2006-01-19 17:14:45 +0000
committerxue <>2006-01-19 17:14:45 +0000
commit598fac7617264c20b5c7e6f914b5aba18a677b01 (patch)
tree08f916e232872b1309142176e12cc4d3a62e7f3b /framework/Web/UI
parentf56a3799ded6b18c98eb9810d9e4c79a9c23c796 (diff)
Fix a few issues with listcontrols about databinding.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/WebControls/TDataBoundControl.php2
-rw-r--r--framework/Web/UI/WebControls/TListControl.php18
2 files changed, 11 insertions, 9 deletions
diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php
index 1108e0f6..aa177f07 100644
--- a/framework/Web/UI/WebControls/TDataBoundControl.php
+++ b/framework/Web/UI/WebControls/TDataBoundControl.php
@@ -334,7 +334,7 @@ abstract class TDataBoundControl extends TWebControl
return $list;
}
else if(is_array($value))
- return new TList($value);
+ return new TMap($value);
else if(($value instanceof Traversable) || $value===null)
return $value;
else
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 537df7c5..d15a7bf1 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -43,11 +43,11 @@ Prado::using('System.Web.UI.WebControls.TDataBoundControl');
* The latter two are covered in {@link TDataBoundControl}. To specify items via
* template, using the following template syntax:
* <code>
- * &lt;com:TListControl&gt;
- * &lt;com:TListItem Value="xxx" Text="yyy" &gt;
- * &lt;com:TListItem Value="xxx" Text="yyy" Selected="true" &gt;
- * &lt;com:TListItem Value="xxx" Text="yyy" &gt;
- * &lt;/com:TListControl&gt;
+ * <com:TListControl>
+ * <com:TListItem Value="xxx" Text="yyy" >
+ * <com:TListItem Value="xxx" Text="yyy" Selected="true" >
+ * <com:TListItem Value="xxx" Text="yyy" >
+ * </com:TListControl>
* </code>
*
* When {@link setDataSource DataSource} or {@link setDataSourceID DataSourceID}
@@ -167,16 +167,18 @@ abstract class TListControl extends TDataBoundControl
if($valueField==='')
$valueField=1;
$textFormat=$this->getDataTextFormatString();
- foreach($data as $object)
+ foreach($data as $key=>$object)
{
$item=new TListItem;
- if(isset($object[$textField]))
+ if(!is_string($object) && isset($object[$textField]))
$text=$object[$textField];
else
$text=TPropertyValue::ensureString($object);
$item->setText($textFormat===''?$text:sprintf($textFormat,$text));
- if(isset($object[$valueField]))
+ if(!is_string($object) && isset($object[$valueField]))
$item->setValue($object[$valueField]);
+ else if(!is_integer($key))
+ $item->setValue($key);
$items->add($item);
}
}