How to programmatically create a title for a new node? I want the title field of each new node of the Agenda content type to be constructed automatically from a date field in that same node.

I have variously tried setting the #default_value and #value on the $form array in hook_form_FORM_ID_alter() but without effect.

How can I achieve this?
Here's how to do it with an entity builder callback. 

&lt;?php

use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;

//Implements hook_form_FORM_ID_alter()
function agenda_form_node_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {

    $form['title']['#access'] = FALSE;
    $form['#entity_builders'][] = 'agenda_node_builder';

}

function agenda_node_builder($entity_type, NodeInterface $node, $form, FormStateInterface $form_state)
{

    $date_of_meeting = $node-&gt;field_date_of_meeting-&gt;date-&gt;format('Y-m-d');
    $node-&gt;setTitle('Agenda for meeting on '.$date_of_meeting);

}    


Notes: 


I found that the callback had to be set up in hook_form_BASE_FORM_ID_alter() rather than hook_form_FORM_ID_alter in which case it didn't get called.
Didn't get to the bottom of this but it's probably something to do with the fact that alter hooks are called in the following order: hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_ID_alter().
Nodes #entity_builders offer a Node entity object for modification before being stored when the form is eventually submitted. 


Thanks to @Berdir for the pointers.