-2

after the core update some how the form alter set field was broken, I tried multiple methods but its not working like :

$form['field_trip_reference']['widget']['#default_value'] = array(820);
$form['field_trip_reference']['widget'][0]['target_id']['#default_value'] = \Drupal\node\Entity\Node::load(820); $form['field_trip_reference']['widget'][0]['target_id']['#value'] = \Drupal\node\Entity\Node::load(820);
$form['field_trip_reference']['widget'][0]['target_id']['#default_value'] = 820; $form['field_trip_reference']['widget'][0]['target_id']['#value'] = 820; $form['field_trip_reference']['widget'][0]['target_id'] = \Drupal\node\Entity\Node::load(820);
$form['field_trip_reference']['widget'][0]['target_id'] = 820;
$form['field_trip_reference']['widget']['target_id']['#default_value'] = 'node:820';

anything that needs to updated?

0

turns out I am overwriting the form and the one that is working for me is :

$form['field_reference']['widget']['#default_value'] = $thenodeid;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.