Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Uwe Fricke

Line break in gridview in admin pages-area?

Good day!

In the backend, under the “pages” section, I have created a custom field as an information field for important changes on the respective pages. It is a text area field from the Advanced Custom Fields (ACF) app. Although ACF offers the option to enable line breaks for the text area field, this has no effect on the grid view. As a result, my notes become very difficult to read.

Is there a way to enforce the line breaks from the text field in the grid view?

Thank you for any help!

2 weeks, 5 days ago
Stefan van den Dungen Gronovius
Developer

The only way to change this behavior is when you use our `ac/column/value’ hook. I write a snippet for you that checks for an ACF column and the mentioned settings and alters the value to use instead of newlines.

add_filter('ac/column/value', function ($value, $id, AC\Column $column) {
    if ($column instanceof ACA\ACF\Column) {
        $acf_settings = $column->get_field()->get_settings();

        if ($acf_settings['type'] === 'textarea' && $acf_settings['new_lines'] === 'br' && $value) {
            return nl2br(get_field($column->get_meta_key(), $id, false));
        }
    }

    return $value;
}, 10, 3);

2 weeks, 4 days ago

You must be logged in to reply to this topic.