mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Undeprecated a critical feature of TableField, and reimplemented in the Group's permission field. Cleaned up its implementation to be more in line with TableListField
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61370 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
73be80c2e5
commit
8505039954
@ -14,8 +14,8 @@
|
|||||||
* @param $sourceClass string The source class of this field
|
* @param $sourceClass string The source class of this field
|
||||||
* @param $fieldList array An array of field headings of Fieldname => Heading Text (eg. heading1)
|
* @param $fieldList array An array of field headings of Fieldname => Heading Text (eg. heading1)
|
||||||
* @param $fieldTypes array An array of field types of fieldname => fieldType (eg. formfield). Do not use for extra data/hiddenfields.
|
* @param $fieldTypes array An array of field types of fieldname => fieldType (eg. formfield). Do not use for extra data/hiddenfields.
|
||||||
* @param $filterField string DEPRECATED The actual limiting filter, eg. 1 (please use $sourceFilter in the form "ParentID = 1" instead)
|
* @param $filterField string The field to filter by. Give the filter value in $sourceFilter. The value will automatically be set on new records.
|
||||||
* @param $sourceFilter string The filter you wish to limit the objects by
|
* @param $sourceFilter string If $filterField has a value, then this is the value to filter by. Otherwise, it is a SQL filter expression.
|
||||||
* @param $editExisting boolean (Note: Has to stay on this position for legacy reasons)
|
* @param $editExisting boolean (Note: Has to stay on this position for legacy reasons)
|
||||||
* @param $sourceSort string
|
* @param $sourceSort string
|
||||||
* @param $sourceJoin string
|
* @param $sourceJoin string
|
||||||
@ -94,7 +94,8 @@ class TableField extends TableListField {
|
|||||||
$this->filterField = $filterField;
|
$this->filterField = $filterField;
|
||||||
|
|
||||||
$this->editExisting = $editExisting;
|
$this->editExisting = $editExisting;
|
||||||
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
|
|
||||||
|
parent::__construct($name, $sourceClass, $fieldList, $filterField ? "$filterField = $sourceFilter" : $sourceFilter, $sourceSort, $sourceJoin);
|
||||||
|
|
||||||
Requirements::javascript('sapphire/javascript/TableField.js');
|
Requirements::javascript('sapphire/javascript/TableField.js');
|
||||||
}
|
}
|
||||||
@ -138,18 +139,11 @@ class TableField extends TableListField {
|
|||||||
} elseif($this->cachedSourceItems) {
|
} elseif($this->cachedSourceItems) {
|
||||||
$items = $this->cachedSourceItems;
|
$items = $this->cachedSourceItems;
|
||||||
} else {
|
} else {
|
||||||
if(!empty($this->filterField) && intval($this->sourceFilter) > 0) {
|
// get query
|
||||||
// Legacy: If a filterField is specified and the sourceFilter is a valid ID (old format)
|
$dataQuery = $this->getQuery();
|
||||||
$SQL_filter = Convert::raw2sql($this->sourceFilter);
|
// get data
|
||||||
$SQL_filterField = $this->filterField;
|
$records = $dataQuery->execute();
|
||||||
$items = DataObject::get($this->sourceClass,"`$SQL_filterField` = '$SQL_filter'", $this->sourceSort, $this->sourceJoin);
|
$items = singleton($this->sourceClass)->buildDataObjectSet($records);
|
||||||
} else {
|
|
||||||
// get query
|
|
||||||
$dataQuery = $this->getQuery();
|
|
||||||
// get data
|
|
||||||
$records = $dataQuery->execute();
|
|
||||||
$items = singleton($this->sourceClass)->buildDataObjectSet($records);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
@ -373,7 +367,7 @@ class TableField extends TableListField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Legacy: Use the filter as a predefined relationship-ID
|
// Legacy: Use the filter as a predefined relationship-ID
|
||||||
if(!empty($this->filterField) && intval($this->sourceFilter) > 0) {
|
if(!empty($this->filterField) && $this->sourceFilter) {
|
||||||
$filterField = $this->filterField;
|
$filterField = $this->filterField;
|
||||||
$obj->$filterField = $this->sourceFilter;
|
$obj->$filterField = $this->sourceFilter;
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ class Group extends DataObject {
|
|||||||
"Code" => "PermissionDropdownField",
|
"Code" => "PermissionDropdownField",
|
||||||
"Arg" => "TextField",
|
"Arg" => "TextField",
|
||||||
),
|
),
|
||||||
null,
|
"GroupID",
|
||||||
"GroupID = {$this->ID}"
|
$this->ID
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user