You are here

public function SimilarTermsField::buildOptionsForm in Similar By Terms 8

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

Overrides FieldPluginBase::buildOptionsForm

File

src/Plugin/views/field/SimilarTermsField.php, line 42

Class

SimilarTermsField
Shows the similarity of the node.

Namespace

Drupal\similarterms\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $form['count_type'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Display type'),
    '#default_value' => $this->options['count_type'],
    '#options' => [
      0 => $this
        ->t('Show count of common terms'),
      1 => $this
        ->t('Show as percentage'),
    ],
  ];
  $form['percent_suffix'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Append % when showing percentage'),
    '#default_value' => !empty($this->options['percent_suffix']),
  ];
  parent::buildOptionsForm($form, $form_state);
}