How reset $form_state on ajax call for get real value in submit? I have see some post about that,but i still have no real answer.

In my form, user can select a register address in a select field.
When he select an address, the ajax set value on some other fields : 




  The code :


  if($form_state-&gt;getTriggeringElement()['#name']=="mes_adresses")
  {
      $listAdresse = $this-&gt;adresse_service-&gt;getUserAdresseById($form_state-&gt;getValue('mes_adresses'));

  }


  $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison'] = array(
      '#title' =&gt; 'Nom de livraison',
      '#type' =&gt; 'textfield',
      '#value' =&gt; $listAdresse['nom'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison'] = array(
      '#title' =&gt; 'Prénom de livraison',
      '#type' =&gt; 'textfield',
      '#value' =&gt; $listAdresse['prenom'],
  );



  $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison'] = array(
      '#title' =&gt; 'Pays de livraison',
      '#type' =&gt; 'select',
      '#required'=&gt;true,
      '#options'=&gt;$this-&gt;taxonomy_service-&gt;getTermsByVid('pays_livraison'),      
      '#value' =&gt; $listAdresse['pays'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison'] = array(
      '#title' =&gt; 'Adresse de livraison',
      '#type' =&gt; 'textfield',
      '#value' =&gt;  $listAdresse['adresse'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison'] = array(
      '#title' =&gt; 'Adresse de livraison',
      '#type' =&gt; 'textfield',
      '#value' =&gt;$listAdresse['adresse2'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison'] = array(
      '#title' =&gt; 'Code postal de livraison',
      '#maxlength'=&gt;5,
      '#type' =&gt; 'textfield',
      '#value' =&gt; $listAdresse['code_postal'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison'] = array(
      '#title' =&gt; 'Ville de livraison',
      '#type' =&gt; 'textfield',
      '#value' =&gt;$listAdresse['ville'],
  );



  And the callback :


public function ajaxChangeAdresseCallback(array &amp;$form, FormStateInterface $form_state)
{

    $form_state-&gt;setRebuild(TRUE);
    return  $form['containerGeneral']['livraison']['adresseComplete'];

}


So there are 2 things :


  #value


If you set value like that, user can never change the value because

$form_state-&gt;getValue()


ll keep the value set by the ajax.


  #default_value


If you set the value like that, that doesn't work because the #default_value parameter if use just the first time the form is loaded.


  The main problem is with $form_state.


If you kint when you submit your form $form_state->getValue() and $_POST, $_POST is good but not the $form_state.

But the issue are in the validate function too, if user select the option new address, ajax reload the form, set empty everywhere, and when you submit, the validate function ll tell you you have empty value.

I know on D7 some people unset the $form_state['values];

But on D8 ?

So how reset the $form_state value ?
Thank to @4k4 for the solution posted here : 

How do I change the default value of a field with AJAX?

For my problem, this is how i add this feature :

$form['containerGeneral']['livraison']['adresseComplete'] = array(
          '#type' =&gt; 'container',
          '#prefix'=&gt;'  &lt;div id="adresseComplete"&gt;',
          '#suffix'=&gt;'&lt;/div&gt;'
      );

      $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison']['#tree']=true;
      $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison']['#tree']=true;

      if($form_state-&gt;getTriggeringElement()['#name']=="mes_adresses")
      {

          $_SESSION['compteur']++;

          $listAdresse = $this-&gt;adresse_service-&gt;getUserAdresseById($form_state-&gt;getValue('mes_adresses'));

          $key = $_SESSION['compteur'];


      }


      $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison'][$key] = array(
          '#title' =&gt; 'Nom de livraison',
          '#type' =&gt; 'textfield',
          '#required'=&gt;true,
          '#placeholder' =&gt; 'Nom',
          '#default_value' =&gt; $listAdresse['nom'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison'][$key] = array(
          '#title' =&gt; 'Prénom de livraison',
          '#type' =&gt; 'textfield',
          '#required'=&gt;true,
          '#default_value' =&gt; $listAdresse['prenom'],
      );



      $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison'][$key] = array(
          '#title' =&gt; 'Pays de livraison',
          '#type' =&gt; 'select',
          '#options'=&gt;$this-&gt;taxonomy_service-&gt;getTermsByVid('pays_livraison'),
          '#default_value' =&gt;  $listAdresse['pays_livraison'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison'][$key] = array(
          '#title' =&gt; 'Adresse de livraison',
          '#type' =&gt; 'textfield',
          '#required'=&gt;true,
          '#placeholder' =&gt; 'Adresse de livraison',
          '#default_value' =&gt;  $listAdresse['adresse'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison'][$key] = array(
          '#title' =&gt; 'Adresse de livraison',
          '#type' =&gt; 'textfield',
          '#default_value' =&gt;$listAdresse['adresse2'],
      );

      $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison'][$key] = array(
          '#title' =&gt; 'Code postal de livraison',
          '#maxlength'=&gt;5,
          '#type' =&gt; 'textfield',
          '#placeholder' =&gt; 'Code postal de livraison',
          '#default_value' =&gt; $listAdresse['code_postal'],

      );

      $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison'][$key] = array(
          '#title' =&gt; 'Ville de livraison',
          '#type' =&gt; 'textfield',
          '#placeholder' =&gt; 'Ville de livraison',
          '#default_value' =&gt;$listAdresse['ville'],
      );


Don't forget to set $_SESSION['compteur'] to 0 on submit and to set it to 0 on form load.