Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Serialized.php

function Serialized::buildOptionsForm

Overrides FieldPluginBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/field/Serialized.php, line 30

Class

Serialized
Field handler to show data of serialized fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $form['format'] = [
        '#type' => 'select',
        '#title' => $this->t('Display format'),
        '#description' => $this->t('How should the serialized data be displayed. You can choose a custom array/object key or a print_r on the full output.'),
        '#options' => [
            'unserialized' => $this->t('Full data (unserialized)'),
            'serialized' => $this->t('Full data (serialized)'),
            'key' => $this->t('A certain key'),
        ],
        '#default_value' => $this->options['format'],
    ];
    $form['key'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Which key should be displayed'),
        '#default_value' => $this->options['key'],
        '#states' => [
            'visible' => [
                ':input[name="options[format]"]' => [
                    'value' => 'key',
                ],
            ],
        ],
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal