You are here

public function Serialized::buildOptionsForm in Drupal 10

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