mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Allow overriding TableListField_Item on TableListField by setting the property itemClass
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98428 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
f1ee9d45d5
commit
8b1367794e
@ -76,6 +76,11 @@ class TableListField extends FormField {
|
|||||||
*/
|
*/
|
||||||
protected $template = "TableListField";
|
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?
|
* @var bool Do we use checkboxes to mark records, or delete them one by one?
|
||||||
*/
|
*/
|
||||||
@ -467,8 +472,7 @@ JS
|
|||||||
function Items() {
|
function Items() {
|
||||||
$fieldItems = new DataObjectSet();
|
$fieldItems = new DataObjectSet();
|
||||||
if($items = $this->sourceItems()) foreach($items as $item) {
|
if($items = $this->sourceItems()) foreach($items as $item) {
|
||||||
$fieldItem = new TableListField_Item($item, $this);
|
if($item) $fieldItems->push(new $this->itemClass($item, $this));
|
||||||
if($item) $fieldItems->push(new TableListField_Item($item, $this));
|
|
||||||
}
|
}
|
||||||
return $fieldItems;
|
return $fieldItems;
|
||||||
}
|
}
|
||||||
@ -670,7 +674,7 @@ JS
|
|||||||
foreach($groupedItems as $key => $group) {
|
foreach($groupedItems as $key => $group) {
|
||||||
$fieldItems = new DataObjectSet();
|
$fieldItems = new DataObjectSet();
|
||||||
foreach($group as $item) {
|
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(
|
$groupedArrItems->push(new ArrayData(array(
|
||||||
'Items' => $fieldItems,
|
'Items' => $fieldItems,
|
||||||
@ -953,7 +957,7 @@ JS
|
|||||||
$className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName'];
|
$className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName'];
|
||||||
$item = new $className($item);
|
$item = new $className($item);
|
||||||
}
|
}
|
||||||
$fieldItem = new TableListField_Item($item, $this);
|
$fieldItem = new $this->itemClass($item, $this);
|
||||||
|
|
||||||
$fields = $fieldItem->Fields(false);
|
$fields = $fieldItem->Fields(false);
|
||||||
$columnData = array();
|
$columnData = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user