How can i set the value of first field to the second in same form I have a form with a value field and i would like to set the value to a markup field as shown below. The problem is that it retuns empty. Is there other alternatives.


public function buildForm(array $form, FormStateInterface $form_state) {
     $form['container']['#tree'] = TRUE;
     $form['container']['#type'] = 'container';
     $form['container']['store_value'] = [
         '#type' => 'value',
         '#value' => 'Angeline Mnene'
     ];
     $form['container']['show_value'] = [
         '#type' => 'markup',
         '#markup' => 'The stored value is: ' . $form_state-
          >getValue(['container','store_value']),
     ];

     return $form;
}
I finally got an answer and would like to post it here, to help someone who may run into this problem as well.


public function buildForm(array $form, FormStateInterface $form_state) {

     //SET THE VALUE HERE
     $form_state->setValue('store_value', 'The stored value is: Angeline 
     Mnene');

     $form['container']['#tree'] = TRUE;
     $form['container']['#type'] = 'container';
     $form['container']['show_value'] = [
         '#type' => 'markup',
         '#markup' => 'The stored value is: ' . $form_state-
          >getValue('store_value'),
     ];

     return $form;
}