Skip to content
Snippets Groups Projects
Unverified Commit 2bc4bb0a authored by Doug Green's avatar Doug Green
Browse files

Issue #3396150 by peximo: Add new line support in CPS review

parent 8ff4f661
No related branches found
No related tags found
No related merge requests found
......@@ -617,3 +617,30 @@ function cps_review_cps_move_changeset($changeset_from, $changeset_to, $entity_t
->execute();
}
}
/**
* Implements hook_field_formatter_info().
*/
function cps_review_field_formatter_info() {
return [
'nl2br' => [
'label' => nt('New line to br'),
'field types' => ['text_long'],
'description' => nt('Convert new lines to br.'),
],
];
}
/**
* Implements hook_field_formatter_view().
*/
function cps_review_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = [];
if ($display['type'] === 'nl2br') {
foreach ($items as $delta => $item) {
$output = _text_sanitize($instance, $langcode, $item, 'value');
$element[$delta]['#markup'] = nl2br($output);
}
}
return $element;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment