Skip to content

Commit

Permalink
Merge pull request #1742 from forkcms/1737-datagrid-button-casing
Browse files Browse the repository at this point in the history
Make sure the column name check is case insensitive
  • Loading branch information
carakas committed Sep 20, 2016
2 parents 7834f7d + 0dd8269 commit 3675d7c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Backend/Core/Engine/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ public function addColumn(
$image = null,
$sequence = null
) {
// make sure we use a lowercased column in all checks
$lowercasedName = mb_strtolower($name);

$icon = $this->decideIcon($name);

// known actions that should have a button
if (in_array(
$name,
$lowercasedName,
array('add', 'edit', 'delete', 'detail', 'details', 'approve', 'mark_as_spam', 'install')
)
) {
Expand All @@ -132,7 +135,7 @@ public function addColumn(
$URL = null;
}

if (in_array($name, array('use_revision', 'use_draft'))) {
if (in_array($lowercasedName, array('use_revision', 'use_draft'))) {
// rebuild value, it should have special markup
$value =
'<a href="' . $URL . '" class="btn btn-default btn-xs">' .
Expand All @@ -149,7 +152,7 @@ public function addColumn(

// known actions
if (in_array(
$name,
$lowercasedName,
array(
'add',
'edit',
Expand Down Expand Up @@ -620,12 +623,12 @@ public function setURL($URL, $append = false)
*/
private function decideIcon($name)
{
$icon = null;
$name = mb_strtolower($name);

if (isset($this->mapIcons[$name])) {
$icon = $this->mapIcons[$name];
if (!isset($this->mapIcons[$name])) {
return null;
}

return $icon;
return $this->mapIcons[$name];
}
}

0 comments on commit 3675d7c

Please sign in to comment.