How can I have default field values for the node add form as arguments in the URL? I have a path in drupal 6, which allow me to add new content with 2 fields completed. For example, path node/add/my_content_type/4/6 means that I am on page /node/add/my_content_type, and first field has value &quot;Philip&quot; and second field has value &quot;Oleg&quot;. Those names are in database, because user put them in in another content type.
I try to do the same in Drupal 8, but I cannot put arguments after /mycontent_type/. So right now, on the /node/add/my_content_type I see a form with fields, I can select names in input select, but nothing shows when I put more arguments in url.
I will give an example:
I have a module with students and school trip. On custom content &quot;students&quot;, I add students names in text input. Those names are saved in database.
Let's say, that my second content type is &quot;trip&quot;.
I have a function, which allow me to add a trip, when students names are given. I can simply click add content 'trip' and select names in select fields, but I want to make it more simple and redirect to page /node/add/trip/4/6 where 4 is id of &quot;Philip&quot; and 6 is id of &quot;Oleg&quot;. In this way I have a form with to fields already completed. It is posible in drupal 6, but no in drupal 8. Have can i do that?
I think that one of the problem could be the fact, that Drupal 8 require field &quot;Title&quot;. So I have to modify url a little bit /node/add/trip/??TITLE??/4/6.
I need exactly this -&gt; https://www.drupal.org/forum/support/module-development-and-code-questions/2020-04-27/webform-field-default-value-from-url
but for custom content :)
I figured it out.
in .module, hook_form_after()
$value = \Drupal::request()-&gt;query-&gt;get('q');
$value = Html::escape($value);
$form['student']['widget']['#default_value'] = [0 =&gt; $value];

with url /node/add/trip?q=6, where 6 is id of student Oleg