diff --git a/src/View/Helper/CrudViewHelper.php b/src/View/Helper/CrudViewHelper.php index 542cae89..de7bdc54 100644 --- a/src/View/Helper/CrudViewHelper.php +++ b/src/View/Helper/CrudViewHelper.php @@ -122,13 +122,7 @@ public function introspect($field, $value, array $options = []) return $output['output']; } - - $schema = $this->schema(); - if (method_exists($schema, 'baseColumnType')) { - $type = $schema->baseColumnType($field); - } else { - $type = $schema->columnType($field); - } + $type = $this->columnType($field); if ($type === 'boolean') { return $this->formatBoolean($field, $value, $options); @@ -145,12 +139,28 @@ public function introspect($field, $value, array $options = []) $value = $this->formatString($field, $value); if ($field === $this->getViewVar('displayField')) { - $value = $this->createViewLink($value, ['escape' => false]); + return $this->formatdisplayField($value, $options); } return $value; } + /** + * Get column type from schema. + * + * @param string $field Field to get column type for + * @return string + */ + public function columnType($field) + { + $schema = $this->schema(); + if (method_exists($schema, 'baseColumnType')) { + return $schema->baseColumnType($field); + } + + return $schema->columnType($field); + } + /** * Format a boolean value for display * @@ -211,6 +221,18 @@ public function formatString($field, $value) return h(Text::truncate($value, 200)); } + /** + * Format display field value. + * + * @param string $value Display field value. + * @param array $options Field options. + * @return string + */ + public function formatDisplayField($value, array $options) + { + return $this->createViewLink($value, ['escape' => false]); + } + /** * Returns a formatted relation output for a given field *