Skip to content
This repository
Browse code

FIX 7590: Image thumbnails broken in gridfield

Delay converting the object to a string and escaping its value until the end of getColumnContent. Call formatValue BEFORE castValue, so that formatValue can create raw HTML by casting to HTMLText afterwards.
  • Loading branch information...
commit 15e2efb55d982053bb3cf6a1a7472bcf58119e1d 1 parent 5591017
jakr authored July 26, 2012 hafriedlander committed July 27, 2012

Showing 1 changed file with 7 additions and 5 deletions. Show diff stats Hide diff stats

  1. 12  forms/gridfield/GridFieldDataColumns.php
12  forms/gridfield/GridFieldDataColumns.php
@@ -94,7 +94,7 @@ public function getFieldCasting() {
94 94
 	 * Caution: Make sure to escape special php-characters like in a normal php-statement.
95 95
 	 * Example:	"myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>'.
96 96
 	 * Alternatively, pass a anonymous function, which takes two parameters:
97  
-	 *  The value returned by Convert::raw2xml and the original list item.
  97
+	 *  The value and the original list item.
98 98
 	 *
99 99
 	 * @param array $formatting
100 100
 	 */
@@ -126,18 +126,20 @@ public function getColumnContent($gridField, $record, $columnName) {
126 126
 		// Allow callbacks
127 127
 		if(is_array($columnInfo) && isset($columnInfo['callback'])) {
128 128
 			$method = $columnInfo['callback'];
129  
-			$value = Convert::raw2xml($method($record));
  129
+			$value = $method($record);
130 130
 		
131 131
 		// This supports simple FieldName syntax
132 132
 		} else {
133  
-			$value = Convert::raw2xml($gridField->getDataFieldValue($record, $columnName));
  133
+			$value = $gridField->getDataFieldValue($record, $columnName);
134 134
 		}
135 135
 
136  
-		$value = $this->castValue($gridField, $columnName, $value);
137 136
 		$value = $this->formatValue($gridField, $record, $columnName, $value);
  137
+		$value = $this->castValue($gridField, $columnName, $value);
138 138
 		$value = $this->escapeValue($gridField, $value);
139 139
 
140  
-		return $value;
  140
+		return (is_object($value) && $value instanceof Object && $value->hasMethod('forTemplate')) 
  141
+			? $value->forTemplate()
  142
+			: Convert::raw2xml($value);
141 143
 	}
142 144
 	
143 145
 	/**

0 notes on commit 15e2efb

Please sign in to comment.
Something went wrong with that request. Please try again.