You are here

public function RssFields::buildOptionsForm in Views (for Drupal 7) 8.3

Provide a form for setting options.

Overrides RowPluginBase::buildOptionsForm

File

lib/Drupal/views/Plugin/views/row/RssFields.php, line 45
Definition of 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, &$form_state) {
  parent::buildOptionsForm($form, $form_state);
  $initial_labels = array(
    '' => 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' => t('Title field'),
    '#description' => 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' => t('Link field'),
    '#description' => 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' => t('Description field'),
    '#description' => 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' => t('Creator field'),
    '#description' => 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' => t('Publication date field'),
    '#description' => 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' => 'fieldset',
    '#title' => t('GUID settings'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['guid_field_options']['guid_field'] = array(
    '#type' => 'select',
    '#title' => t('GUID field'),
    '#description' => 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' => t('GUID is permalink'),
    '#description' => t('The RSS item GUID is a permalink.'),
    '#default_value' => $this->options['guid_field_options']['guid_field_is_permalink'],
  );
}