public function JsonFeedFields::buildOptionsForm in JSON Feed 8
Provide a form for setting options.
Overrides RowPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ row/ JsonFeedFields.php, line 42
Class
- JsonFeedFields
- Plugin which displays fields for a JSON feed.
Namespace
Drupal\json_feed\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['id_field'] = [
'#type' => 'select',
'#title' => $this
->t('id attribute'),
'#description' => $this
->t('Unique identifier for this item over time.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['id_field'],
'#required' => TRUE,
];
$form['url_field'] = [
'#type' => 'select',
'#title' => $this
->t('url attribute'),
'#description' => $this
->t('Permanent link to this item.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['url_field'],
'#required' => TRUE,
];
$form['external_url_field'] = [
'#type' => 'select',
'#title' => $this
->t('external_url attribute'),
'#description' => $this
->t('URL of a page elsewhere that this item is referencing.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['external_url_field'],
];
$form['title_field'] = [
'#type' => 'select',
'#title' => $this
->t('title attribute'),
'#description' => $this
->t('JSON title attribute. This must be plain text, not linked to the content.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['title_field'],
];
$form['content_html_field'] = [
'#type' => 'select',
'#title' => $this
->t('content_html attribute'),
'#description' => $this
->t('JSON content_html attribute. This is the only attribute in the JSON Feed spec that allows HTML.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['content_html_field'],
];
$form['content_text_field'] = [
'#type' => 'select',
'#title' => $this
->t('content_text attribute'),
'#description' => $this
->t('JSON content_text attribute.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['content_text_field'],
];
$form['summary_field'] = [
'#type' => 'select',
'#title' => $this
->t('summary attribute'),
'#description' => $this
->t('JSON summary attribute. This must be plain text.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['summary_field'],
];
$form['image_field'] = [
'#type' => 'select',
'#title' => $this
->t('image attribute'),
'#description' => $this
->t('The URL of the main image for the item. Feed readers may use the image as a preview.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['image_field'],
];
$form['banner_image_field'] = [
'#type' => 'select',
'#title' => $this
->t('banner image attribute'),
'#description' => $this
->t('The URL of an image to use as a banner. A feed reader with a detail view may choose to show this banner image at the top of the detail view, possibly with the title overlaid.'),
'#options' => $view_fields_labels,
'#default_value' => $this->options['banner_image_field'],
];
$form['date_published_field'] = [
'#type' => 'select',
'#title' => $this
->t('date_published attribute'),
'#description' => $this
->t("JSON date_published attribute, formatted as RFC 3339 (Y-m-d\\TH:i:sP)"),
'#options' => $view_fields_labels,
'#default_value' => $this->options['date_published_field'],
];
$form['date_modified_field'] = [
'#type' => 'select',
'#title' => $this
->t('date_modified attribute'),
'#description' => $this
->t("JSON date_modified attribute, formatted as RFC 3339 (Y-m-d\\TH:i:sP)"),
'#options' => $view_fields_labels,
'#default_value' => $this->options['date_modified_field'],
];
$form['tags_field'] = [
'#type' => 'select',
'#title' => $this
->t('tags attribute'),
'#description' => $this
->t("JSON tags attribute. Accepts a comma separated list of tag names."),
'#options' => $view_fields_labels,
'#default_value' => $this->options['tags_field'],
];
$form['author'] = [
'#type' => 'details',
'#title' => $this
->t('Author'),
'#open' => TRUE,
];
$form['author_name_field'] = [
'#fieldset' => 'author',
'#type' => 'select',
'#title' => $this
->t('item author name attribute'),
'#description' => $this
->t("JSON author name attribute."),
'#options' => $view_fields_labels,
'#default_value' => $this->options['author_name_field'],
];
$form['author_url_field'] = [
'#fieldset' => 'author',
'#type' => 'select',
'#title' => $this
->t('item author url attribute'),
'#description' => $this
->t("The URL of a site owned by the item's author."),
'#options' => $view_fields_labels,
'#default_value' => $this->options['author_url_field'],
];
$form['author_avatar_field'] = [
'#fieldset' => 'author',
'#type' => 'select',
'#title' => $this
->t('item author avatar attribute'),
'#description' => $this
->t("The URL for an image for the item's author."),
'#options' => $view_fields_labels,
'#default_value' => $this->options['author_avatar_field'],
];
}