You are here

public function Serialized::buildOptionsForm in Views (for Drupal 7) 8.3

Default options form that provides the label widget that all fields should have.

Overrides FieldPluginBase::buildOptionsForm

File

lib/Drupal/views/Plugin/views/field/Serialized.php, line 31
Definition of Drupal\views\Plugin\views\field\Serialized.

Class

Serialized
Field handler to show data of serialized fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function buildOptionsForm(&$form, &$form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['format'] = array(
    '#type' => 'select',
    '#title' => t('Display format'),
    '#description' => 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' => array(
      'unserialized' => t('Full data (unserialized)'),
      'serialized' => t('Full data (serialized)'),
      'key' => t('A certain key'),
    ),
    '#default_value' => $this->options['format'],
  );
  $form['key'] = array(
    '#type' => 'textfield',
    '#title' => t('Which key should be displayed'),
    '#default_value' => $this->options['key'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[format]"]' => array(
          'value' => 'key',
        ),
      ),
    ),
  );
}