mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2875 from kinglozzer/2361-gridfield-column-header-css
FIX: Ensure valid CSS classes for GridField header (fixes #2361)
This commit is contained in:
commit
bc8d2d638e
@ -92,6 +92,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
|||||||
foreach($columns as $columnField) {
|
foreach($columns as $columnField) {
|
||||||
$currentColumn++;
|
$currentColumn++;
|
||||||
$metadata = $gridField->getColumnMetadata($columnField);
|
$metadata = $gridField->getColumnMetadata($columnField);
|
||||||
|
$fieldName = str_replace('.', '-', $columnField);
|
||||||
$title = $metadata['title'];
|
$title = $metadata['title'];
|
||||||
|
|
||||||
if(isset($this->fieldSorting[$columnField]) && $this->fieldSorting[$columnField]) {
|
if(isset($this->fieldSorting[$columnField]) && $this->fieldSorting[$columnField]) {
|
||||||
@ -132,7 +133,7 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
|||||||
}
|
}
|
||||||
|
|
||||||
$field = Object::create(
|
$field = Object::create(
|
||||||
'GridField_FormAction', $gridField, 'SetOrder'.$columnField, $title,
|
'GridField_FormAction', $gridField, 'SetOrder'.$fieldName, $title,
|
||||||
"sort$dir", array('SortColumn' => $columnField)
|
"sort$dir", array('SortColumn' => $columnField)
|
||||||
)->addExtraClass('ss-gridfield-sort');
|
)->addExtraClass('ss-gridfield-sort');
|
||||||
|
|
||||||
@ -148,10 +149,10 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
|||||||
if($currentColumn == count($columns)
|
if($currentColumn == count($columns)
|
||||||
&& $gridField->getConfig()->getComponentByType('GridFieldFilterHeader')){
|
&& $gridField->getConfig()->getComponentByType('GridFieldFilterHeader')){
|
||||||
|
|
||||||
$field = new LiteralField($columnField,
|
$field = new LiteralField($fieldName,
|
||||||
'<button name="showFilter" class="ss-gridfield-button-filter trigger"></button>');
|
'<button name="showFilter" class="ss-gridfield-button-filter trigger"></button>');
|
||||||
} else {
|
} else {
|
||||||
$field = new LiteralField($columnField, '<span class="non-sortable">' . $title . '</span>');
|
$field = new LiteralField($fieldName, '<span class="non-sortable">' . $title . '</span>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$forTemplate->Fields->push($field);
|
$forTemplate->Fields->push($field);
|
||||||
|
Loading…
Reference in New Issue
Block a user