You are here

public function Length::buildOptionsForm in Ubercart 8.4

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

Overrides NumericField::buildOptionsForm

File

uc_store/src/Plugin/views/field/Length.php, line 32

Class

Length
Field handler to provide formatted lengths.

Namespace

Drupal\uc_store\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['format'] = [
    '#title' => $this
      ->t('Format'),
    '#type' => 'radios',
    '#options' => [
      'uc_weight' => $this
        ->t('Ubercart length'),
      'numeric' => $this
        ->t('Numeric'),
    ],
    '#default_value' => $this->options['format'],
    '#weight' => -1,
  ];
  foreach ([
    'separator',
    'format_plural',
    'prefix',
    'suffix',
  ] as $field) {
    $form[$field]['#states']['visible']['input[name="options[format]"]']['value'] = 'numeric';
  }
}