Example #1
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['format'] = array('#title' => t('Format'), '#type' => 'radios', '#options' => array('uc_weight' => t('Ubercart length'), 'numeric' => t('Numeric')), '#default_value' => $this->options['format'], '#weight' => -1);
     foreach (array('separator', 'format_plural', 'prefix', 'suffix') as $field) {
         $form[$field]['#states']['visible']['input[name="options[format]"]']['value'] = 'numeric';
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     // Add a start point selector.
     // Add the proximity field group.
     $form['proximity_group'] = ['#type' => 'fieldset', '#title' => $this->t('Proximity Settings')];
     // Add the source selector.
     $form['proximity_source'] = ['#type' => 'select', '#title' => $this->t('Select the source type.'), '#description' => $this->t('To calculate proximity we need a starting point to compare the field value to. Select where to get the start location.'), '#default_value' => $this->options['proximity_source'], '#fieldset' => 'proximity_group', '#options' => ['direct_input' => $this->t('Direct Input'), 'filter' => $this->t('Filter Settings'), 'argument' => $this->t('Contextual Filter')]];
     // Add the Latitude field for direct input.
     $form['proximity_lat'] = ['#type' => 'textfield', '#title' => $this->t('Latitude'), '#empty_value' => '', '#default_value' => $this->options['proximity_lat'], '#maxlength' => 255, '#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]];
     // Add the Latitude field for direct input.
     $form['proximity_lng'] = ['#type' => 'textfield', '#title' => $this->t('Longitude'), '#empty_value' => '', '#default_value' => $this->options['proximity_lng'], '#maxlength' => 255, '#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]];
     $form['units'] = ['#type' => 'select', '#title' => $this->t('Units'), '#default_value' => !empty($this->options['units']) ? $this->options['units'] : '', '#weight' => 40, '#fieldset' => 'proximity_group', '#options' => ['mile' => $this->t('Miles'), 'km' => $this->t('Kilometers')], '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]];
     // Buffer available  filters.
     $valid_filters = [];
     // Check for valid filters.
     foreach ($this->view->getHandlers('filter', $this->view->current_display) as $delta => $filter) {
         if ($filter['plugin_id'] === 'geolocation_filter_proximity') {
             $valid_filters[$delta] = $filter['id'];
         }
     }
     // Add the Filter selector.
     $form['proximity_filter'] = empty($valid_filters) ? ['#markup' => $this->t('There are no proximity filters available in this display.')] : ['#type' => 'select', '#title' => $this->t('Select filter.'), '#description' => $this->t('Select the filter to use as the starting point for calculating proximity.'), '#options' => $valid_filters];
     $form['proximity_filter'] += ['#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'filter']]]];
     // Buffer available  filters.
     $valid_arguments = [];
     // Check for valid filters.
     foreach ($this->view->getHandlers('argument', $this->view->current_display) as $delta => $filter) {
         if ($filter['plugin_id'] === 'geolocation_argument_proximity') {
             $valid_arguments[$delta] = $filter['id'];
         }
     }
     // Add the Filter selector.
     $form['proximity_argument'] = empty($valid_arguments) ? ['#markup' => $this->t('There are no proximity contextual filters (arguments) available in this display.')] : ['#type' => 'select', '#title' => $this->t('Select contextual filter (argument).'), '#description' => $this->t('Select the contextual filter (argument) to use as the starting point for calculating proximity.'), '#options' => $valid_arguments];
     $form['proximity_argument'] += ['#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'argument']]]];
     // Add the Drupal\views\Plugin\views\field\Numeric settings to the form.
     parent::buildOptionsForm($form, $form_state);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['link_to_comment'] = array('#title' => $this->t('Link this field to new comments'), '#description' => $this->t("Enable to override this field's links."), '#type' => 'checkbox', '#default_value' => $this->options['link_to_comment']);
     parent::buildOptionsForm($form, $form_state);
 }