Skip saving empty paragraphs for certain types

Created on 11 May 2017, almost 8 years ago
Updated 16 February 2023, about 2 years ago

Problem/Motivation

If the paragraphs field is not required but it's widget has a default paragraph type selected this results in the required fields from of the paragraph to still be validated - and if empty the validation for the host entity fails.

If there are none required fields, the empty paragraph item is still saved. This could cause labels with empty items displayes

Another use case can be found in paragraphs collection where we have a paragraph type "separator" that does its job without having any field filled. So it needs to save although all fields are empty.

Proposed resolution

Add an option to skip save if all fields are empty on each paragraph type.

Required fields would still trigger validation.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India saranya ashokkumar

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇸🇰Slovakia coaston

    #44 worked for me, But without #46 I would not notice it, so thank you @lexsoft.

  • First commit to issue fork.
  • Pipeline finished with Failed
    9 months ago
    Total: 349s
    #196558
  • Pipeline finished with Canceled
    8 months ago
    #197453
  • Pipeline finished with Failed
    8 months ago
    Total: 498s
    #197454
  • Pipeline finished with Success
    8 months ago
    Total: 325s
    #221545
  • 🇨🇳China m0925j

    We still have this problem in drupal version 10.2.6, paragraph version 8.x-1.17, what I want is for the default to not create an empty paragraph entity when no value is filled in, for the default to display the paragraph widget in the node creation form, and for the default to not create an empty paragraph entity when the Add paragraph button is clicked but no value is actually filled in. Instead of having to be manually removed by the user.

  • 🇦🇷Argentina abelpzl

    I ran into the same problem on drupal 10.3.1 and paragraphs 1.17.
    The merge request made by Codebymikey solved my problem.

  • Status changed to RTBC 7 months ago
  • 🇮🇳India diwakar07

    Hi,

    I reviewed MR !118 on drupal 10.3.0 and paragraphs 1.17, it successfully fixes the issue.
    It adds an option in the paragraph type edit form to Enable/Disable

    Save paragraph instances, even when fields are empty

    , by default it is enabled.

    On disabling this option, I was able to save the node by adding a blank paragraph type, and no label was rendered for the blank paragraph type added on node.
    Attached are the SS for references.

    This looks good to me.
    Moving to RTBC!

    Thanks.

  • Status changed to Needs work 7 months ago
  • 🇨🇭Switzerland berdir Switzerland

    Reviewed.

  • 🇮🇳India sourav_paul Kolkata

    I've checked the issue On D10.3.3.
    MR!118 was applied cleanly .

    MR fixed the issue.

    Attaching SS:

    Before applying the MR:

    After applying the MR:

  • Pipeline finished with Success
    5 months ago
    Total: 265s
    #298048
  • 🇮🇳India sourav_paul Kolkata

    I've resolved the review changes..

    Please Review the updated changes.

  • Pipeline finished with Success
    5 months ago
    Total: 323s
    #298745
  • Updated the PR and requesting further review of the changes.

    Would ideally be nice if a test was also introduced as part of this change to avoid unintentionally breaking it.

    I don't have time to write a functional test for it at the moment, but if someone else wants to have a go at it, you're more than free to!

  • Status changed to Needs review 4 months ago
  • 🇮🇳India sourav_paul Kolkata

    @berdir Could you please look into it?

  • codebymikey changed the visibility of the branch skip to hidden.

  • 🇺🇦Ukraine voleger Ukraine, Rivne

    Uploading the MR 118 diff as a patch for composer patching needs

Production build 0.71.5 2024