Get the submitted values from $form_state Is there a function (in Drupal 8) to build an array containing the submitted values in $form state? If I use $form_state-&gt;getValues(), I get more values than the ones I need.
If you are getting values like form_id, form_token, or form_build_id, which you don't want, then you need to use the following code.

$values = $form_state-&gt;cleanValues()-&gt;getValues();


The documentation for FormState::cleanValues() says:


  This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column. In such cases, all internal Form API values and all form button elements should not be contained, and this function allows their removal before the module proceeds to storage. Next to button elements, the following internal values are removed by default.
  
  
  form_id
  form_token
  form_build_id
  op
  


FormState::cleanValues() returns $this, so it can be used in chained calls, as in the code I showed.