I have a custom views filter extending Drupal\user\Plugin\views\filter\Name
that I am trying to add an additional form element. The existing filter is an autocomplete field that I need to add a checkbox element. I've tried updating ::valueForm
.
// Working code that creates the autocomplete field.
$existingElement = $form['value'];
$form['value'] = [
'#tree' => TRUE,
'existing_element' => $existingElement,
'new_element' => [
'#type' => 'checkbox',
'#title' => t('Checkbox'),
'#default_value' => FALSE,
],
];
It throws this error.
Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of core/lib/Drupal/Component/Utility/NestedArray.php).
It seems to be related to the form state, but I have troubles in figuring out exactly what is missing.