public function DataFieldRow::buildOptionsForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm()
- 9 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm()
File
- core/
modules/ rest/ src/ Plugin/ views/ row/ DataFieldRow.php, line 72
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'] ?? '',
];
}
}
}