Insert a value to $form_state function form_example_form($form, &amp;$form_state) {
      $form_state ['store_value'] =1;
      $form['submit_button'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Click Here!'),
      );


  return $form;
}


How to do this in drupal 8
Insert the the value in $form_state:

$form_state-&gt;set('store_value', 1);


And then later for example in submitForm():

$value = $form_state-&gt;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:

$form_state is now a classed object