function DataFieldRow::buildOptionsForm
Same name in other branches
- 9 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm()
- 8.9.x core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm()
- 11.x core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm()
Overrides RowPluginBase::buildOptionsForm
File
-
core/
modules/ rest/ src/ Plugin/ views/ row/ DataFieldRow.php, line 73
Class
- DataFieldRow
- Plugin which displays fields as raw data.
Namespace
Drupal\rest\Plugin\views\rowCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['field_options'] = [
'#type' => 'table',
'#header' => [
$this->t('Field'),
$this->t('Alias'),
$this->t('Raw output'),
],
'#empty' => $this->t('You have no fields. Add some to your view.'),
'#tree' => TRUE,
];
$options = $this->options['field_options'];
if ($fields = $this->view->display_handler
->getOption('fields')) {
foreach ($fields as $id => $field) {
// Don't show the field if it has been excluded.
if (!empty($field['exclude'])) {
continue;
}
$form['field_options'][$id]['field'] = [
'#markup' => $id,
];
$form['field_options'][$id]['alias'] = [
'#title' => $this->t('Alias for @id', [
'@id' => $id,
]),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#default_value' => $options[$id]['alias'] ?? '',
'#element_validate' => [
[
$this,
'validateAliasName',
],
],
];
$form['field_options'][$id]['raw_output'] = [
'#title' => $this->t('Raw output for @id', [
'@id' => $id,
]),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => $options[$id]['raw_output'] ?? '',
];
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.