From 4b7400f20c6d2076cb13eed96c09036b429ac9e2 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 13 Aug 2021 10:13:57 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1094 --- .../MarkupAdminDataTable.module | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module b/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module index d83f2e43..43bca8b4 100644 --- a/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module +++ b/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module @@ -156,7 +156,8 @@ class MarkupAdminDataTable extends ModuleJS { * * @param array $a Array of columns that will each be a ``, where each element may be one of the following: * - `string`: converts to `string` - * - `array('label' => 'url')`: converts to `label` + * - `$a["key"] = "value"`: converts to `key` + * - `array('label' => 'url')`: converts to `label` (same as above, but in nested array with count 1) * - `array('label', 'class')`: converts to `label` * @param array $options Optionally specify any one of the following: * - separator (bool): specify true to show a stronger visual separator above the column @@ -193,10 +194,18 @@ class MarkupAdminDataTable extends ModuleJS { $row = array(); foreach($a as $k => $v) { + if(is_array($v) && count($v) === 1 && is_int($k)) { + // array('label' => 'href') + $key = key($v); + $v = reset($v); + if(is_string($key)) $k = $key; + } if(is_string($k)) { // Associative arrays get converted to: // Anchor Text => URL - $v = "" . $this->encode($k) . ""; + $v = $this->encode($v); + $k = $this->encode($k); + $v = "$k"; } else if(is_array($v)) { // class name is specified in $v[1] foreach($v as $kk => $vv) {