public function RssFields::buildOptionsForm in Drupal 9
Same name and namespace in other branches
- 8 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 40
Class
- RssFields
- Renders an RSS item based on fields.
Namespace
Drupal\views\Plugin\views\rowCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$initial_labels = [
'' => $this
->t('- None -'),
];
$view_fields_labels = $this->displayHandler
->getFieldLabels();
$view_fields_labels = array_merge($initial_labels, $view_fields_labels);
$form['title_field'] = [
'#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'] = [
'#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 either be an internal unprocessed path like "node/123" or a processed, root-relative URL as produced by fields like "Link to content".'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['link_field'],
'#required' => TRUE,
];
$form['description_field'] = [
'#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'] = [
'#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'] = [
'#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'] = [
'#type' => 'details',
'#title' => $this
->t('GUID settings'),
'#open' => TRUE,
];
$form['guid_field_options']['guid_field'] = [
'#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'] = [
'#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'],
];
}