I want to add some arbitrary variable to store it in the form_state and use it again so in one of my ajax callback functions I set a property named var:
public function MyFunctionCallback(array &$form, FormStateInterface &$form_state) {
....
$terms = array('1'=>'one','2'=>'two');
$form_state->set('var', $terms);
....
}
it works and the storage array of the form_state has var element
unfortunately when trying to get the var back inside another callback function it returns null. actually with debugging the storage array of the form_state is empty
public function MyOtherFunctionCallback(array &$form, FormStateInterface &$form_state) {
....
$terms = $form_state->get('var');
....
}