Filter with additional form element 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' =&gt; TRUE,
  'existing_element' =&gt; $existingElement,
  'new_element' =&gt; [
    '#type' =&gt; 'checkbox',
    '#title' =&gt; t('Checkbox'),
    '#default_value' =&gt; 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.
You probably need to override the valueValidate method to tell it about the new structure:
protected function valueValidate($form, FormStateInterface $form_state) {
  $uids = [];
  if ($values = $form_state-&gt;getValue(['options', 'value', 'existing_element'])) {
    foreach ($values as $value) {
      $uids[] = $value['target_id'];
    }
    sort($uids);
  }

  $checkbox_value = $form_state-&gt;getValue(['options', 'value', 'new_element']);
  // Do something with $checkbox_value here as you're going to lose it

  $form_state-&gt;setValue(['options', 'value'], $uids);
}