summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls')
-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);
}
}