I have a custom form that I created programmatically.
$target_type = 'node';
$selection_handler = 'default';
$selection_settings = ['page'];
$data = serialize($selection_settings) . $target_type . $selection_handler;
$selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt());
$key_value_storage = \Drupal::keyValue('entity_autocomplete');
if (!$key_value_storage->has($selection_settings_key)) {
$key_value_storage->set($selection_settings_key, $selection_settings);
}
$form['terms_default_node'] = [
'#type' => 'textfield',
'#title' => $this->t('Terms of Business - default page'),
'#autocomplete_route_name' => 'system.entity_autocomplete',
'#autocomplete_route_parameters' => [
'target_type' => $target_type,
'selection_handler' => $selection_handler,
'selection_settings_key' => $selection_settings_key,
],
'#default_value' => \Drupal\node\Entity\Node::load(1)->value, // What do I put here?
];
I don't get how to make the default value of the field be "Terms of Business (1)".
Autocomplete works, saving works, but I don't know how to recall that saved value again and make it as default_value
when I open this form again.
This field doesn't have any widgets, etc. And I can't find anything in Google