On my site (drupal 9.2.8) users add content and there is no need to put any information to 'Title' field. I was trying to make this field not required via form_alter in custom module but it did not work:
function yourmodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
if ($form['#form_id'] == 'node_somenode_form' or $form['#form_id'] == 'node_somenode_form'){
$form['title']['widget']['0']['#required'] = FALSE; // not working
$form['title']['widget']['#required'] = FALSE; // not working
$form['title']['#required'] = FALSE; // not working
}
}
As a workaround in my module I prefill Title using form_alter:
$form['title']['widget']['0']['value']['#default_value'] = 'any default title';
and then just hide this field from form. There are a few ways of doing that (In form alter what is the different way of hiding fields and what is the difference between them? ), I decided to use hide:
hide($form['title']);
but I am curies why ['#required'] = FALSE;
doesn't work for Title field but it works fine with other fields.