// Set the value for a form element with ID "my_element". $form_state->setValueForElement('my_element', 'my_value');
// Set the value to an array of values for a form element with ID "my_element". $form_state->setValueForElement('my_element', array('value1', 'value2', 'value3'));This code snippet sets an array of values for the "my_element" form element. In both examples, the FormStateInterface is the package library used. This interface is a part of the Drupal core library, which is responsible for providing basic functionality for all Drupal modules.