0

I'm new to Drupal 8.

I need to let users to create new node of some content type by pressing a button or custom link. In Drupal 7 I could achieve this by Rules and Rules link modules but I can't figure out how to do it in D8.

Let's assume I have a content type where all fields have default values and I want to create new node of this content type just by pressing a custom button.

How can I get this working in D8? Any tips?

1

Add a link for the route node.add in Twig:

<a href="{{ path('node.add', {'node_type': 'page'}) }}">{{ 'Add content of type "Basic Page"'|t }}</a>
0

If you set Permissions for the particular user Role to Create new nodes of a certain type, then simply linking them to the Node add page for that type is enough:

node/add/article

Because you have set the default value of each Field on your Content type, the Fields will already be prepopulated with the same default value.

The user will see the Create form, then just click on the Save button at the end.

To skip the Create form and automatically create the node with the default values you'll have to set up Rules with some custom components, or help convert the Rules link module to D8: https://www.drupal.org/project/rules_link/issues/2619740

If you need to prepopulate the fields with different default values you can use the Prepopulate module.

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.