Problem/Motivation
The error happens when the paragraph has a required but disabled(hidden) field and it's collapsed.
P.S. The issue looks like duplicate of the #3030966: Closed paragraph validation error: This value should not be null but it's not.
Steps to reproduce
Quick reproduce:
- Make a paragraph with required field + some non required field/fields
- Go to the form display and disable the required field.
- Make a new content type with Paragraph field
- Create a new node of the new content type + add the new paragraph type to the content field
- Fill in visible fields and collapse the paragraph
- Press Save the content
Real case:
- We have a paragraph with the required field
- The paragraph has two form displays: on the first one the required field is disabled and enabled on the second one
- PA: the required field is disabled
- PB: the required field is enabled
- We have two content types where:
- CA: use paragraph with form display PA - means that required field is hidden and isn't used for this content type
- CB: use paragraph with form display PB - means that required field exists on the form and required for filling
- Result when we save the content with the collapsed paragraph:
- CA: Error "Validation error on collapsed paragraph : This value should not be null."
- CB: works es expected
Proposed resolution
We need to exclude hidden fields from the validation.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Screenshot 2022-12-30 at 11.13.50 PM.png | 467.59 KB | deepalij |
| #6 | Screenshot 2022-12-30 at 11.06.26 PM.png | 206.65 KB | deepalij |
| #5 | Before patch.png | 74.18 KB | deepalij |
| #4 | validation-error-on-collapsed-paragraph-3321404-4.patch | 848 bytes | hitchshock |
Issue fork paragraphs-3321404
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hitchshockComment #3
hitchshockComment #4
hitchshockComment #5
deepalij commentedApplied patch #4 on Drupal 10.1.x-dev
Patch applied cleanly
Able to reproduce the issue
The issue got fixed. "Validation error on collapsed paragraph : This value should not be null." is not appearing after applying the patch and getting a success message.
RTBC+1
Comment #6
deepalij commentedComment #7
neclimdulLooking at the patch, it looks like it filters out all validations from hidden fields. That doesn't seem like a good thing, we should still want validation of hidden fields. If I'm miss-reading it could we can add a comment to the code explaining why its ok to filter them?
Comment #8
hitchshock@neclimdul cuz this is normal Drupal behavior to not validate hidden fields on entity form. You can check this by you self:
- add required field to the node
- hide it on the entity form
- on node save action you should not see the error that field is empty
- when the field is visible you will see an error
This is an expected behavior for UI
Paragraph breaks this logic when it's collapsed. But works well when it's expanded.
So we need to fix UI behaviour for the collapsed paragraph case.
Fix was applied to the field widget, it means that only UI behaviour has been fixed. Which is ok.
Comment #9
monymirza#4 RTBC+1
Comment #10
berdirCommitted, agreed that this makes sense.
Comment #13
kescoto-thinkshout commentedHas anyone else continued to see this issue? We are still encountering this error even though we have the latest version of the module.
Comment #14
meryem dibeI agree, the error is still occurring even with the patch applied, any updates on this case ?
Comment #15
drupalam commentedThis issue should be fixed if you update to version 1.17.