Accessing a selected value instead of key in drupal 8 I need to access values instead of keys from a custom form select field. To get the keys, I am using $form_state-&gt;getValue() but I don't know how to access the values. Kindly help.
Assuming that code is in a submit/validate method, you have the original form array available, so you can grab the options straight from the element definition:

$key = $form_state-&gt;getValue('foo');
$val = $form['foo']['#options'][$key];