I have a contact form build from the drupal core contact forms.
I am trying to prefill some fields from URL GET parameters like this. /?foo=bar
But it seems that "default value" doesnt support tokens.
I want to use something like this: [current-page:url:args:value:foo]
in the default field of my form field.
But this gets just rendered as plain text. Any help is appreciated.
EDIT: Working solution with form_alter:
function MY_MODULE_form_alter(&$form, &$form_state) {
$args = \Drupal::request()->query->all();
$form['field_test']['widget'][0]['value']['#default_value'] = $args['foo'];
}
Maybe there is a solution with tokens relating to the topic?