diff options
author | xue <> | 2006-01-19 17:14:45 +0000 |
---|---|---|
committer | xue <> | 2006-01-19 17:14:45 +0000 |
commit | 598fac7617264c20b5c7e6f914b5aba18a677b01 (patch) | |
tree | 08f916e232872b1309142176e12cc4d3a62e7f3b /framework/Web/UI | |
parent | f56a3799ded6b18c98eb9810d9e4c79a9c23c796 (diff) |
Fix a few issues with listcontrols about databinding.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/WebControls/TDataBoundControl.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 18 |
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>
- * <com:TListControl>
- * <com:TListItem Value="xxx" Text="yyy" >
- * <com:TListItem Value="xxx" Text="yyy" Selected="true" >
- * <com:TListItem Value="xxx" Text="yyy" >
- * </com:TListControl>
+ * <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);
}
}
|