use Drupal\Core\Form\FormStateInterface; /** * Implements hook_form_submit(). */ function my_module_form_submit($form, FormStateInterface $form_state) { // Set the value of the "my_text_field" element to "Hello, world!". $form_state->setValue('my_text_field', 'Hello, world!'); }
use Drupal\Core\Form\FormStateInterface; /** * Implements hook_form_submit(). */ function my_module_form_submit($form, FormStateInterface $form_state) { // Set the value of the "my_select_field" element to the second option. $form_state->setValue('my_select_field', 1); }Package library: Drupal core library.