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 "Philip" and second field has value "Oleg". 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 "students", I add students names in text input. Those names are saved in database.
Let's say, that my second content type is "trip". 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 "Philip" and 6 is id of "Oleg". 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 "Title". So I have to modify url a little bit /node/add/trip/??TITLE??/4/6.
I need exactly this -> https://www.drupal.org/forum/support/module-development-and-code-questions/2020-04-27/webform-field-default-value-from-url but for custom content :)
hook_form_alter
implementation. So please try this: Create a custom module to implementhook_form_alter
, learn how to target the desired form, learn how to set default values to existing elements, try to retrieve URL query parameters, and the set them as default values.