You are here

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

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

Overrides Numeric::buildOptionsForm

File

lib/Views/search/Plugin/views/field/Score.php, line 34
Definition of Views\search\Plugin\views\field\Score.

Class

Score
Field handler to provide simple renderer that allows linking to a node.

Namespace

Views\search\Plugin\views\field

Code

public function buildOptionsForm(&$form, &$form_state) {
  $style_options = $this->view->display_handler
    ->getOption('style_options');
  if (isset($style_options['default']) && $style_options['default'] == $this->options['id']) {
    $handlers = $this->view->display_handler
      ->getHandlers('field');
    $options = array(
      '' => t('No alternate'),
    );
    foreach ($handlers as $id => $handler) {
      $options[$id] = $handler
        ->adminLabel();
    }
    $form['alternate_sort'] = array(
      '#type' => 'select',
      '#title' => t('Alternative sort'),
      '#description' => t('Pick an alternative default table sort field to use when the search score field is unavailable.'),
      '#options' => $options,
      '#default_value' => $this->options['alternate_sort'],
    );
    $form['alternate_order'] = array(
      '#type' => 'select',
      '#title' => t('Alternate sort order'),
      '#options' => array(
        'asc' => t('Ascending'),
        'desc' => t('Descending'),
      ),
      '#default_value' => $this->options['alternate_order'],
    );
  }
  parent::buildOptionsForm($form, $form_state);
}