You are here

public function Proximity::valueForm in CiviCRM Entity 8.3

Options form subform for setting options.

This should be overridden by all child classes and it must define $form['value']

Overrides FilterPluginBase::valueForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/Proximity.php, line 98

Class

Proximity
Filter handler for proximity.

Namespace

Drupal\civicrm_entity\Plugin\views\filter

Code

public function valueForm(&$form, FormStateInterface $form_state) {
  $form['value']['#tree'] = TRUE;
  $form['value']['#type'] = 'fieldset';
  $form['value']['city'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('City'),
    '#size' => 30,
    '#default_value' => $this->value['city'],
  ];
  $values = $this->civicrmApi
    ->get('StateProvince', [
    'sequential' => 1,
    'country_id' => static::COUNTRY_ID,
    'options' => [
      'limit' => 0,
    ],
  ]);
  $form['value']['state_province_id'] = [
    '#type' => 'select',
    '#options' => [
      '' => $this
        ->t('- Any -'),
    ] + array_combine(array_column($values, 'id'), array_column($values, 'name')),
    '#title' => $this
      ->t('State/Province'),
    '#default_value' => $this->value['state_province_id'],
  ];
  $form['value']['value'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Postal code'),
    '#size' => 30,
    '#default_value' => $this->value['value'],
  ];
  $form['value']['distance'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Distance'),
    '#default_value' => $this->value['distance'],
  ];
  $form['value']['distance_unit'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Distance unit'),
    '#default_value' => $this->value['distance_unit'],
    '#options' => [
      'miles' => $this
        ->t('Miles'),
      'kilometers' => $this
        ->t('Kilometers'),
    ],
  ];
}