ReactJS - How to create ReactJS components
Introduction In this post, we will talk about basic of how to create components…
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 this post, we will talk about basic of how to create components…
Suppose you have two lists, and you want Union and Intersection of those two…
Problem Statement I’ve been using image styles, and heavily used “Scale and crop…
Note: This is based on bootstrap-4 If you are using multi column design in your…
Introduction I had to develop a small automation to query some old mysql data…
I use drupal-7 in my website. I used to write articles and put images in that…
Introduction This post has the complete code to send email through smtp server…
Introduction In a normal email sending code from python, I’m getting following…
Introduction In one of my app, I was using to talk to . I have used some event…
Introduction So you have a Django project, and want to run it using docker image…
Introduction It is very important to introduce few process so that your code and…
Introduction In this post, we will see a sample Jenkin Pipeline Groovy script…