Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

REST Views

Security covered Under active development 3,860 sites

This module enhances the REST Export display for Drupal Views, allowing for more flexible and accurate data serialization. It enables fields to be exported as arrays, nested structures for entity references, and proper JSON primitives for boolean and numeric types, addressing limitations of the default Views rendering.

REST Views

This module enhances the functionality of Views that use the REST Export display to export serialized data.

Introduction

When you create a view with a REST Export display, you will quickly encounter hard limitations on the data structure, imposed by the Views module's reliance on the Render API:

  • You may want to export a field with multiple values as an array. By default, this is only possible by exporting the raw field, as the rendering process also concatenates the output into a single string.

  • An entity reference can only be exported as a fully rendered string, and not as a nested structure with multiple individual fields.

  • Boolean and numeric fields can only be exported as strings, rather than the appropriate JSON primitives.

  • Contributed module exports (Such as paragraphs, geo field, and search api) require their respective sub modules to be enabled as well.

The Views and Field plugins in this module add all of these features.

Usage

After installing this module, each entity field can be accessed in Views via a new handler named "Field (Serializable)".

This field handler automatically exports multiple-value fields as arrays. This is dependent on the cardinality in the schema, so it will be applied even if the field contains less than two actual values.

Furthermore, the following fields will have new field formatters designed to export non-string values:

(Note that these will only work in combination with the Serializable handler.)

Nested entity references: In general these require a custom display mode where the fields are formatted with export formats unless you want rendered html. See the links below for specific discussions.

Extending

You can create your own field formatter plugins that export arbitrary data structures based on a field's values:

 $item) {
      $data = '[A data structure based on $item.]';
      $elements[$delta] = [
        '#type' => 'data',
        '#data' => SerializedData::create($data),
      ];
    }

    return $elements;
  }

}

Security

This module does not add any output filtering beyond that which has already been applied. In practice this means:

  • All fields with normal non-Export formatters (including those inside referenced entities) are rendered, and therefore contain safe HTML markup, provided their modules are working securely.
  • The Export field formatters export raw values.

If both kinds of formatters are used in the same view, clients should be made aware which values are markup and which are untreated strings. In all cases, the client application is responsible for safely using the exported data.

Drupal 10–11 PHP ^8

Ask your assistant about REST Views

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • rest Drupal core
  • views Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
8
Tracked since
Jan 2023
Latest release
4 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
3.x-dev Dev 10–11 Jun 15, 2026
3.1.1 Stable 10–11 PHP ^8 Jul 31, 2024
3.1.0 Stable 10–11 PHP ^8 Jul 17, 2024
3.0.1 Stable 9–10 PHP ^8 Apr 23, 2024
3.0.0 Stable 9–10 PHP ^8 Jan 23, 2024
3.0.0-rc1 Pre-release 9–10 PHP ^8 Jan 4, 2024
3.0.0-alpha1 Pre-release 9–10 PHP ^8 Oct 5, 2023
3.0.x-dev Dev 10–11 PHP ^8 Jan 30, 2023