In form validation I have to set value of a hidden field. I tried like below
\Drupal::formBuilder()->setValue($form['maintenance_type'], 'R', $form_state); form_set_value($form['maintenance_type'], 'I', $form_state);
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
Insert the the value in $form_state:
And then later for example in submitForm():
$value = $form_state->get('store_value');
Don't use getValue() or setValue(), because this is for submitted values.
If you are migrating more forms from D7 to D8, use this as reference: