I need to modify the node title while saving the node ID. I implemented hook_form_FORM_ID_alter()
as follows.
/**
* Implements hook_form_FORM_ID_alter()
*/
function module_name_form_form_id_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['title']['#access'] = FALSE;
$form['#entity_builders'][] = 'change_node_title';
}
function change_node_title($entity_type, NodeInterface $node, $form, FormStateInterface $form_state) {
$node_id = $node->nid->value; // Not getting the node details
$node->setTitle('Custom Title -' . $node_id);
}
The node details aren't found from the #entity_builders callback.
How can modify the node title before saving it? I don't want to use any custom modules for this. I don't want to use hook_node_presave()
either, as it would affect the cloned nodes.