I need to get in hook_node_insert
and hook_node_update
the value of a field I manually added to a form.
function hook_form_FORMID_alter(&$form, FormStateInterface $formState, $form_id) {
$form['newfield'] = [
'#title' => 'New field',
'#type' => 'checkbox',
];
}
In Drupal 7 every form field is copied to the entity and it's easy to access it as explained here Get data form into hook_node_insert / hook_node_update
Is there a way in Drupal 8 too?