ReactJS - How to pass method to component and how to pass arguments to method
Introduction In the ReactJS project, you are having aa parent component and a…
April 04, 2020
Drupal is an awesome CMS. Drupal content type form, allows you to add fields with unlimited occurence. This is how it used to happen already in drupal (Assumming you already having a content type)
Now, what this unlimited means is that when your form renders. It gives you a button which allows you to add more of this field on each click.
Now, lets take an example content type. Assume you are having a products review page. And, you would want to show multiple products. And for each product, you want to have 3 different fields:
Lets take a look how this form will look like:
Now you see, for each of multi-value field, you are seeing a separate button for “Add More”. And, what we want is to have a set of fields and expand them separately by a single button click.
Drupal has an awesome out of the box module for this kind of problem named: Paragraphs.
Lets install this module:
composer require drupal/paragraphs
It also installs a dependency module (Entity Reference Revisions). After this command, lets enable this from modules section in drupal.
After this, goto: /admin/structure/paragraphs_type Note, we want those three fields to be treated as a set. And, a single button for adding that set multiple times.
In paragraph types, we will create a new Paragraph Type. It is almost similar to adding a new content type and its fields.
Now, add those three fields in this paragraph type just like in a new content type. Most important, For each field in this paragraph type. Set its “Allowed Number of values” to just 1. Not unlimited.
After adding all fields, it will look like:
Now, go back to your content type and Manage fields. Assumming you don’t have any existing content for this content type.
Finally, in your content type. You are left with:
And, you can see your expected form.
I hope you are getting the expected output. If you want your form to look more awesome. You can also install another module Field Groups. It will allow you to visibally group your set of fields. And, your form will look more real.
I hope above steps will solve your needs. I’m repeating above steps:
I hope you enjoy reading it.
Introduction In the ReactJS project, you are having aa parent component and a…
Introduction In Azure, assuming you are having a storage container. And, you…
Introduction Assume you have a drupal website and using cloudflare. You are…
You can either do tail -f drupal.log or open it in an editor like vim.
Tag the image, by seeing its image id, from docker images command docker tag 04d…
Introduction Twig is a powerful template engine for php. Drupal uses it heavily…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…