You are here

public function VariableAttributeCustomization::buildOptionsForm in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_query/src/Plugin/views/VariableAttributeCustomization.php \Drupal\ldap_query\Plugin\views\VariableAttributeCustomization::buildOptionsForm()
1 call to VariableAttributeCustomization::buildOptionsForm()
LdapVariableImageAttribute::buildOptionsForm in ldap_query/src/Plugin/views/field/LdapVariableImageAttribute.php
1 method overrides VariableAttributeCustomization::buildOptionsForm()
LdapVariableImageAttribute::buildOptionsForm in ldap_query/src/Plugin/views/field/LdapVariableImageAttribute.php

File

ldap_query/src/Plugin/views/VariableAttributeCustomization.php, line 25

Class

VariableAttributeCustomization
Collates the variable attribute customization to apply it to more than one.

Namespace

Drupal\ldap_query\Plugin\views

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $queryOptions = $this->view
    ->getDisplay()
    ->getOption('query')['options'];
  if (!isset($queryOptions['query_id']) || empty($queryOptions['query_id'])) {
    $form['attribute_name'] = [
      '#markup' => 'You must select a valid LDAP search (Advanced => Query settings)',
    ];
    return;
  }
  $controller = new QueryController($queryOptions['query_id']);
  $controller
    ->execute();
  $options = $controller
    ->availableFields();
  $form['attribute_name'] = [
    '#type' => 'select',
    '#title' => t('Attribute name'),
    '#description' => t('The attribute name from LDAP response'),
    '#options' => $options,
    '#default_value' => $this->options['attribute_name'],
    '#required' => TRUE,
  ];
}