raw_fields_formatters
Security covered
RAW Fields Formatters
Overview
Available formatters
Formatter
Field types
Extra settings
Raw Boolean
Optional dependencies
Usage with RawRenderer
Requirements
Installation
Maintainers
Provides raw field formatters for Drupal, designed to expose field values as structured data. Primarily intended for use with Single-Directory Components (SDC) and JSON rendering pipelines.
Overview
Each formatter outputs raw typed values (string, integer, boolean, float, array) instead of rendered HTML, making it straightforward to pass field data directly to SDC component props.
All formatters share two common settings:
- Override default key with â Override the key used when the renderer collects field data.
- Force as array â Always output a list, even when there is only one value.
Available formatters
Formatter
Field types
Extra settings
Raw Boolean
boolean
â
Raw Decimal
decimal, float
â
Raw Formatted Text
text, text_long, text_with_summary
â
Raw Geolocation Lat/Lng
geolocation
â
Raw Icon
ui_icon
â
Raw Image URL
image
Image style
Raw Integer
integer
â
Raw List Value
list_integer, list_float, list_string
â
Raw Entity
entity_reference
View mode
Raw Paragraph
entity_reference_revisions
View mode
Raw String
string, string_long, telephone
â
Raw URL
link
â
Optional dependencies
Some formatters require a contrib module to be useful:
- Raw Geolocation Lat/Lng â requires Geolocation
- Raw Icon â requires UI Icons
- Raw Paragraph â requires Entity Reference Revisions (included in Paragraphs)
Usage with RawRenderer
Use the raw_fields_formatters.renderer service to collect the rendered data into a plain PHP array:
$renderer = \Drupal::service('raw_fields_formatters.renderer');
$variables = ['elements' => $build];
$renderer->renderData($variables);
$data = $variables['data'];
Requirements
- Drupal 10 or 11
- PHP 8.1+
Installation
Install as any other Drupal module via Composer:
composer require drupal/raw_fields_formatters
drush en raw_fields_formatters