If you create a required field on the paragraph entity, and make the paragraph collapsible on the parent node (or entity), the user can add a paragraph entity without filling in the required field, collapse the paragraph, and save the node (or entity). Marked as critical as site functionality should be able to depend on required fields not being empty.

Comments

choicelildice created an issue. See original summary.

Webbeh’s picture

matthijs’s picture

Status: Active » Needs review
StatusFileSize
new641 bytes

I can confirm this issue, the attached patch fixes this by validating the submitted values on collapse.

matthijs’s picture

StatusFileSize
new641 bytes

My previous patch changed the wrong form builder property, here's a new one :-)

gadaniels72’s picture

This is a different issue than https://www.drupal.org/node/2558517; in that issue, the requiredness of a paragraph item is not validated as required (so if I add a field "test" of type "paragraphs" and make it required, it does not throw an error if I do not add a paragraph item. This issue happens when one has a required field within the paragraph bundle (for example, paragraph bundle "p-test" has a required field of "label." If I add a field "test" of type "paragraphs" and set the open type to "preview" and then press "add paragraph item" and "collapse" and save, the p-test field is not actually required.

gadaniels72’s picture

Status: Needs review » Reviewed & tested by the community

Tested the patch #4 and it does work. To test, I:

  • Created a paragraph bundle with a required field
  • Added a not-required field to my content type of type paragraphs
  • Set the Default Edit Mode to "preview" to enable the collapse button
  • Added a node, added a paragraph item, left the required field empty and pressed Collapse
  • Verified that I see a "[field name] field is required" message when trying to collapse the paragraph item.
jeroen.b’s picture

Thanks @Matthijs and @gadaniels72 for putting effort and time into this!

I'm currently trying to get the quality of the code up to par with the D8 version.
That mostly just means we need to add many tests to make sure we won't break anything.
Are you able to create a unit test for this? (and provide 2 patches: 1 with the fixed code + test, 1 with the test only. that way we can see the test actually confirms it is fixed now).

jeroen.b’s picture

Status: Reviewed & tested by the community » Needs work
karlshea’s picture

Status: Needs work » Needs review
StatusFileSize
new3.18 KB
new3.81 KB

Tests added

The last submitted patch, 9: paragraphs-validate_on_collapse-tests-2612120-9.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: paragraphs-validate_on_collapse-2612120-9.patch, failed testing.

karlshea’s picture

Test failures are due to #2729173-2: Undefined property while creating new content, not anything to do with Paragraphs.

karlshea’s picture

emmanvazz’s picture

Patch #4 worked for me as well. Thanks!

emmanvazz’s picture

@KarlShea seems like #2807275 is fixed, now to wait for Entity API to get updated.

finex’s picture

Hi, the same bug exists on D8 version.

whthat’s picture

Re-queued tests from Patch #9 with success! Entity API patch has been committed #2807275

whthat’s picture

Status: Needs work » Needs review
supriya1992’s picture

supriya1992’s picture

Assigned: Unassigned » supriya1992
Webbeh’s picture

Assigned: supriya1992 » Unassigned

Unassigning supriya1992 from the issue.

Webbeh’s picture

Status: Needs review » Reviewed & tested by the community

The patch supplied in #4 worked well for me, and appears to have worked for folks given #14, #17, #6, so I'm marking this as reviewed & tested pending any major hiccups.

Webbeh’s picture

Attaching D8 version of this issue as a related task.

Webbeh’s picture

  • jstoller committed 0d1cc46 on 7.x-1.x authored by KarlShea
    Issue #2612120 by KarlShea, Matthijs, Webbeh, gadaniels72, emmanvazz:...
jstoller’s picture

Status: Reviewed & tested by the community » Fixed

Patch committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.