You are here

public function TranslationModerationState::buildOptionsForm in Translation Views 8

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

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/TranslationModerationState.php, line 86

Class

TranslationModerationState
Provides a field that adds moderation state.

Namespace

Drupal\translation_views\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $default_value = 'state';
  $states = [
    'state' => $this
      ->t('Moderation State'),
    'name' => $this
      ->t('Machine Name'),
  ];
  if (!empty($this->options['display_name'])) {
    $default_value = $this->options['display_name'];
  }
  $form['display_name'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Formatter'),
    '#options' => $states,
    '#required' => TRUE,
    '#default_value' => $default_value,
  ];
  parent::buildOptionsForm($form, $form_state);
}