How to create temporary select field? I added a field:

$form['field_brand_selector']['#type'] = "select";
$form['field_brand_selector']['#title'] = "Brand";
$form['field_brand_selector']['#required'] = false;


This field is populated dynamically using Javascript. However, if I try to save the form, I get:

Illegal choice 49124 in Brand element.


I suspect that this is because I don't have this:

$form['field_brand_selector']['#options'] = $options;


So Drupal doesn't know which values are allowed for this Dropdown Selector. But seeing as this dropdown selector is not actually a field that must be saved, is there a way to "ignore" it's submission when I press save, so that I don't get the illegal Brand element error?
Probably a hack, but this is how I solved it:

$form['field_brand_selector'] = array(
    '#type' =&gt; 'inline_template',
    '#template' =&gt; '{{ somecontent | raw }}',
    '#context' =&gt; [ 'somecontent' =&gt; 
    '
        &lt;label for="edit-field-brand-selector"&gt;Brand&lt;/label&gt;
        &lt;select class="" id="edit-field-brand-selector" name="field_brand_selector" readonly="readonly"&gt;&lt;/select&gt;
    '],
    '#weight' =&gt; 8,
);


This way Drupal doesn't validate the field I added.