0

I integrated a custom database table to views using hook_views_data().

$data['custom_watchdog']['message'] = [
    'title' => 'Message',
    'help' => 'Full log message.',
    'field' => [
        'id' => 'standard',
    ],
    'filter' => [
        'id' => 'string',
    ],
];

It works, as I can display values in a view, but it misses a formatter option.
For example, the Taxonomy term: Description field has formatter options which allows to select Default or Trimmed.

Why isn't it available for my custom field?

1 Answer 1

2

You are comparing a standard Views field with an entity field. Only entity fields have field formatters. Create a custom entity instead of a custom table if you want to use this feature. For a standard field you have to use the options provided by Views. There is a trim option as well, but it is named differently, trim in the alter section. You see it in Views UI. Try to configure it and check the exported View.

1
  • Thank you @4k4 for explanation. Trim was just an example, I was building custom FieldFormatter. At the end I used hook_preprocess_views_view_field() to modify output of the view field. Mar 16, 2021 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.