Options form with FieldPluginBase? I tried some variations on the code below, but I have not been able to pass my custom form options to render().

class CustomField extends FieldPluginBase {

  public function query() {
    // This is a custom field.
    // Leave empty to avoid a query on this field.
  }

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['my_options'] = [
      '1' =&gt; 1,
      '2' =&gt; 2,
      '3' =&gt; 3,
    ];
    return $options;
  }

  public function buildOptionsForm(&amp;$form, FormStateInterface $form_state) {

    //Form select element.
    $form['my_options'] = [
      '#type' =&gt; 'select',
      '#required' =&gt; TRUE,
      '#title' =&gt; $this-&gt;t('My Options'),
      '#options' =&gt; $this-&gt;options['my_options'],
      '#description' =&gt; $this-&gt;t('Description.'),
      '#default_value' =&gt; 1,
    ];
    parent::buildOptionsForm($form, $form_state);
  }

  public function render(ResultRow $values) {
    return kpr($this-&gt;options['my_options']);
  }

}


As is the ['my_options'] key is empty. If I create the $options['my_options'] in buildOptionsForm() it does populate the select list in the views field form. Both, however, break the output of the render(ResultRow $values) function. No errors, just no output.

How do you create and pass options from defineOptions() to buildOptionsForm(), and inevitably access them in render(ResultRow $values)?

Trying to reference:
FieldPluginBase::defineOptions and Field::buildOptionsForm without success. As well as referencing: https://www.webomelette.com/creating-custom-views-field-drupal-8
$this-&gt;options and #options of the select element are two different things.

See the separator field of NumericField::buildOptionsForm:

$form['separator'] = [
  '#type' =&gt; 'select',
  '#title' =&gt; $this-&gt;t('Thousands marker'),
  '#options' =&gt; [
    '' =&gt; $this-&gt;t('- None -'),
    ',' =&gt; $this-&gt;t('Comma'),
    ' ' =&gt; $this-&gt;t('Space'),
    '.' =&gt; $this-&gt;t('Decimal'),
    '\'' =&gt; $this-&gt;t('Apostrophe'),
  ],
  '#default_value' =&gt; $this-&gt;options['separator'],
  '#description' =&gt; $this-&gt;t('What single character to use as the thousands separator.'),
  '#size' =&gt; 2,
];