Drupal version 9.3.9.
This is a process of Ajax callback, where the value of the title field is required. In the form node add, the title is displayed. It seems that the form_state does not apply to the title field. When I inspect the variables, the title field is also not reflected in the values.
function my_custom_module_field_widget_process($element, \Drupal\Core\Form\FormStateInterface $form_state,$form) {
#$element['my_field']['#default_value'] =$form_state->getFormObject()->getEntity()-
#>label();this work, but useless in the callback
if(!empty($form_state->getValue('title'))){
$title = $form_state->getValue('title');
$element['my_field']['#default_value'] = $title;
}
return $element;
}
$form_state->getFormObject()->getEntity()->label();
works but is useless in the callback?