Permalink
Browse files

ENHANCEMENT Allow overriding TableListField_Item on TableListField by…

… setting the property itemClass (merged from r98428)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@98774 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 2fc2d72 commit c3e213b69013408744106a7d5542dd0af426311c @chillu chillu committed Feb 11, 2010
Showing with 8 additions and 4 deletions.
  1. +8 −4 forms/TableListField.php
View
@@ -76,6 +76,11 @@ class TableListField extends FormField {
*/
protected $template = "TableListField";
+ /**
+ * @var $itemClass string Class name for each item/row
+ */
+ public $itemClass = 'TableListField_Item';
+
/**
* @var bool Do we use checkboxes to mark records, or delete them one by one?
*/
@@ -457,8 +462,7 @@ function sourceItems() {
function Items() {
$fieldItems = new DataObjectSet();
if($items = $this->sourceItems()) foreach($items as $item) {
- $fieldItem = new TableListField_Item($item, $this);
- if($item) $fieldItems->push(new TableListField_Item($item, $this));
+ if($item) $fieldItems->push(new $this->itemClass($item, $this));
}
return $fieldItems;
}
@@ -659,7 +663,7 @@ function GroupedItems() {
foreach($groupedItems as $key => $group) {
$fieldItems = new DataObjectSet();
foreach($group as $item) {
- if($item) $fieldItems->push(new TableListField_Item($item, $this));
+ if($item) $fieldItems->push(new $this->itemClass($item, $this));
}
$groupedArrItems->push(new ArrayData(array(
'Items' => $fieldItems,
@@ -957,7 +961,7 @@ function generateExportFileData(&$numColumns, &$numRows) {
$className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName'];
$item = new $className($item);
}
- $fieldItem = new TableListField_Item($item, $this);
+ $fieldItem = new $this->itemClass($item, $this);
$fields = $fieldItem->Fields(false);
$columnData = array();

0 comments on commit c3e213b

Please sign in to comment.