You are here

public function RssFields::buildOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/row/RssFields.php \Drupal\views\Plugin\views\row\RssFields::buildOptionsForm()

Provide a form for setting options.

Overrides RowPluginBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/row/RssFields.php, line 45
Contains \Drupal\views\Plugin\views\row\RssFields.

Class

RssFields
Renders an RSS item based on fields.

Namespace

Drupal\views\Plugin\views\row

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $initial_labels = array(
    '' => $this
      ->t('- None -'),
  );
  $view_fields_labels = $this->displayHandler
    ->getFieldLabels();
  $view_fields_labels = array_merge($initial_labels, $view_fields_labels);
  $form['title_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Title field'),
    '#description' => $this
      ->t('The field that is going to be used as the RSS item title for each row.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['title_field'],
    '#required' => TRUE,
  );
  $form['link_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Link field'),
    '#description' => $this
      ->t('The field that is going to be used as the RSS item link for each row. This must be a drupal relative path.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['link_field'],
    '#required' => TRUE,
  );
  $form['description_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Description field'),
    '#description' => $this
      ->t('The field that is going to be used as the RSS item description for each row.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['description_field'],
    '#required' => TRUE,
  );
  $form['creator_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Creator field'),
    '#description' => $this
      ->t('The field that is going to be used as the RSS item creator for each row.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['creator_field'],
    '#required' => TRUE,
  );
  $form['date_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Publication date field'),
    '#description' => $this
      ->t('The field that is going to be used as the RSS item pubDate for each row. It needs to be in RFC 2822 format.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['date_field'],
    '#required' => TRUE,
  );
  $form['guid_field_options'] = array(
    '#type' => 'details',
    '#title' => $this
      ->t('GUID settings'),
    '#open' => TRUE,
  );
  $form['guid_field_options']['guid_field'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('GUID field'),
    '#description' => $this
      ->t('The globally unique identifier of the RSS item.'),
    '#options' => $view_fields_labels,
    '#default_value' => $this->options['guid_field_options']['guid_field'],
    '#required' => TRUE,
  );
  $form['guid_field_options']['guid_field_is_permalink'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('GUID is permalink'),
    '#description' => $this
      ->t('The RSS item GUID is a permalink.'),
    '#default_value' => $this->options['guid_field_options']['guid_field_is_permalink'],
  );
}