function Serialized::buildOptionsForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::buildOptionsForm()
  2. 10 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::buildOptionsForm()
  3. 11.x core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\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',
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.