public function Feed::buildOptionsForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/display/Feed.php \Drupal\views\Plugin\views\display\Feed::buildOptionsForm()
Provide a form to edit options for this plugin.
Overrides PathPluginBase::buildOptionsForm
File
- core/
modules/ views/ src/ Plugin/ views/ display/ Feed.php, line 263
Class
- Feed
- The plugin that handles a feed, such as RSS or atom.
Namespace
Drupal\views\Plugin\views\displayCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
// It is very important to call the parent function here.
parent::buildOptionsForm($form, $form_state);
switch ($form_state
->get('section')) {
case 'title':
$title = $form['title'];
// A little juggling to move the 'title' field beyond our checkbox.
unset($form['title']);
$form['sitename_title'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use the site name for the title'),
'#default_value' => $this
->getOption('sitename_title'),
];
$form['title'] = $title;
$form['title']['#states'] = [
'visible' => [
':input[name="sitename_title"]' => [
'checked' => FALSE,
],
],
];
break;
case 'displays':
$form['#title'] .= $this
->t('Attach to');
$displays = [];
foreach ($this->view->storage
->get('display') as $display_id => $display) {
// @todo The display plugin should have display_title and id as well.
if ($this->view->displayHandlers
->has($display_id) && $this->view->displayHandlers
->get($display_id)
->acceptAttachments()) {
$displays[$display_id] = $display['display_title'];
}
}
$form['displays'] = [
'#title' => $this
->t('Displays'),
'#type' => 'checkboxes',
'#description' => $this
->t('The feed icon will be available only to the selected displays.'),
'#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', $displays),
'#default_value' => $this
->getOption('displays'),
];
break;
case 'path':
$form['path']['#description'] = $this
->t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.');
}
}