You are here

public function XmlFieldHelperTrait::getDefaultXmlOptionsForm in Views XML Backend 8

Returns the default options form for XML fields.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array The updated form array.

2 calls to XmlFieldHelperTrait::getDefaultXmlOptionsForm()
Date::buildOptionsForm in src/Plugin/views/field/Date.php
Default options form that provides the label widget that all fields should have.
Standard::buildOptionsForm in src/Plugin/views/field/Standard.php
Default options form that provides the label widget that all fields should have.

File

src/Plugin/views/field/XmlFieldHelperTrait.php, line 61
Contains \Drupal\views_xml_backend\Plugin\views\field\XmlFieldHelperTrait.

Class

XmlFieldHelperTrait
A handler to provide an XML text field.

Namespace

Drupal\views_xml_backend\Plugin\views\field

Code

public function getDefaultXmlOptionsForm(array $form, FormStateInterface $form_state) {
  $form['xpath_selector'] = [
    '#title' => $this
      ->t('XPath selector'),
    '#description' => $this
      ->t('The xpath selector'),
    '#type' => 'textfield',
    '#default_value' => $this->options['xpath_selector'],
    '#required' => TRUE,
  ];
  $form['type'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Display type'),
    '#options' => [
      'ul' => $this
        ->t('Unordered list'),
      'ol' => $this
        ->t('Ordered list'),
      'separator' => $this
        ->t('Simple separator'),
    ],
    '#default_value' => $this->options['type'],
  ];
  $form['separator'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Separator'),
    '#default_value' => $this->options['separator'],
    '#states' => [
      'visible' => [
        ':input[name="options[type]"]' => [
          'value' => 'separator',
        ],
      ],
    ],
  ];
  return $form;
}