public function CallbackFieldRow::buildOptionsForm in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Plugin/views/row/CallbackFieldRow.php \Drupal\search_autocomplete\Plugin\views\row\CallbackFieldRow::buildOptionsForm()
Overrides \Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
Overrides RowPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ row/ CallbackFieldRow.php, line 81
Class
- CallbackFieldRow
- Plugin which displays fields as raw data.
Namespace
Drupal\search_autocomplete\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'),
],
'#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) {
$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' => isset($options[$id]['alias']) ? $options[$id]['alias'] : '',
'#element_validate' => [
[
$this,
'validateAliasName',
],
],
];
}
}
}