You are here

public function Xml::buildOptionsForm in Views XML Backend 8

Provide a form to edit options for this plugin.

Overrides PluginBase::buildOptionsForm

File

src/Plugin/views/query/Xml.php, line 170
Contains \Drupal\views_xml_backend\Plugin\views\query\Xml.

Class

Xml
Views query plugin for an XML query.

Namespace

Drupal\views_xml_backend\Plugin\views\query

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['xml_file'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('XML File'),
    '#default_value' => $this->options['xml_file'],
    '#description' => $this
      ->t('The URL or path to the XML file.'),
    '#maxlength' => 1024,
    '#required' => TRUE,
  ];
  $form['row_xpath'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Row Xpath'),
    '#default_value' => $this->options['row_xpath'],
    '#description' => $this
      ->t('An xpath function that selects rows.'),
    '#maxlength' => 1024,
    '#required' => TRUE,
  ];
  $form['default_namespace'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Default namespace'),
    '#default_value' => $this->options['default_namespace'],
    '#description' => $this
      ->t("If the xml contains a default namespace, it will be accessible as 'default:element'. If you want something different, declare it here."),
  ];
  $form['show_errors'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show XML errors'),
    '#default_value' => $this->options['show_errors'],
    '#description' => $this
      ->t('If there were any errors during XML parsing, display them. It is recommended to leave this on during development.'),
  ];
}