drupal2 Min Read

Drupal 8 - Advanced usage of Paragraphs module - Add nested set of fields and single Add more button (No Coding Required)

Gorav Singal

April 06, 2020

TL;DR

Leverage the Paragraphs module to nest paragraph types within each other, enabling complex repeatable field groups with a single Add More button.

Drupal 8 - Advanced usage of Paragraphs module - Add nested set of fields and single Add more button (No Coding Required)

Introduction

In my previous article, I explained How to have set of fields and single Add More button.

In this post, we will see how we can have nested set of fields and we can have a single Add More button for that subset.

Nested Subset and Single Add More button

Let me set context of this article flow. We will discuss following:

Create a content type having fields:

  • Title
  • Body
  • Image for the article
  • Product Details Set (Multiple allowed)

Each Product Details will have following fields:

  • Title
  • Description of product
  • Sub-Product Details (Multiple Allowed)

Each Sub-Product Details will have following fields:

  • Image
  • ASIN code of product

In simpler terms, we will have a content type for a product, in which we can do following:

  • Should be able to add multiple products
  • For each product, we should be able to add multiple images and respective website

Solution

Lets have a look at the step by step guide:

  1. Create a Paragraph Type This is for our Sub-Product details

    • Goto: /admin/structure/paragraphs_type
    • Click on Add Paragraph Type
    • Give a name like Sub-Products
    • Click on Manage fields
    • Add following fields:
      • Product Image
      • ASIN Code of product
      Note: Each of above field is configured to have single value, not multiple. See Using Field Groups for better looking fields
  2. Create another paragraph Type This is for our Product Details

    • Goto: /admin/structure/paragraphs_type
    • Click on Add Paragraph Type
    • Give a name like Products
    • Click on Manage fields
    • Add following fields:
      • Product Title (Text plain)
      • Description of Product (Text Long)
      • Add Paragraph (Under Entity reference), and select above created Paragraph (Product Sub-Details)
      • Above field is set to have Multiple Values.
      See Using Field Groups for better looking fields
  3. Now, create actual Content Type This the actual node for our Product.

    • Create content type, give a name
    • Add following fields
      • Title will comes by default
      • Description field (Text long) This will be an introduction of article
      • Image (For setting main image of article)
      • Now, add Paragraph (From Entity Reference), and select above created Paragraph type: Product Details
      • Set it to have Multiple Values.

Final Look

Lets look at the interested section only.

Drupal Multiple fields example

A more refined image

Drupal Multiple fields example

If you are using Field Groups module, you can have more fun with setting different options for displaying fieldsets.

Share

Related Posts

Drupal 8 - How to hide help link About text formats and text format guidelines

Drupal 8 - How to hide help link About text formats and text format guidelines

Problem In drupal textarea field, it was always a pain to see the two links…

Drupal - Using Field Groups for Visually Separating multiple field set (No Coding Required)

Drupal - Using Field Groups for Visually Separating multiple field set (No Coding Required)

Introduction You are having a form having multiple fields. When you render a…

Drupal - How to add multiple form fields with a single button click (No Coding Required)

Drupal - How to add multiple form fields with a single button click (No Coding Required)

Introduction Drupal is an awesome CMS. Drupal content type form, allows you to…

Drupal 8 - How to Theme Form and its Fields with reordering fields

Drupal 8 - How to Theme Form and its Fields with reordering fields

Introduction In this post, we will see how to theme form and its fields…

Drupal 8 - How to create a Page with admin access and create its menu entry in Reports (No Coding)

Drupal 8 - How to create a Page with admin access and create its menu entry in Reports (No Coding)

Introduction I needed a report page, where I wanted to have some information…

Drupal: How to detect country and redirect to country specific website by using Cloudflare

Drupal: How to detect country and redirect to country specific website by using Cloudflare

Introduction Assume you have a drupal website and using cloudflare. You are…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…