Steps to reproduce:
1. Add a paragraph type with required text field
2. Add paragraph field to basic page and use the experimental widget
3. Create a page and add paragraph with title
4. Add another paragraph and leave title empty
5. Click collapse all or edit the first paragraph (to collapse the second paragraph without title)
6. Click save

Expected result: Field validation fails with a message "title field is required".

Actual result: Field validation fails with a message "This value should not be null".

Comments

olli created an issue. See original summary.

Mark Isherwood’s picture

Not 100% sure if this is the same issue or a problem with Media Library. I encountered this same error message with a required Media field (using Media Library widget), which was nested inside another paragraph. After selecting an image with the media library, the image would not show on the form and the error message would display. The issue occurred both with the experimental and classic paragraphs widget. Only work-around I found was making the media field as non-required

megha_kundar’s picture

Status: Active » Needs review
StatusFileSize
new1.86 KB

Added function for Required field in paragraph types

megha_kundar’s picture

please review

Deeksha B’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new81.6 KB
new59.2 KB

I used above steps in the issue summary, and the patch 3030966-3.patch worked fine for me below is the result.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Active

@Deeksha B - your screenshot shows client side validation by the browser and not a Drupal validation error message - thus unrelated.

@Megha_kundar - A test-only patch is supposed to test the bug, and thus fail until the bug is fixed. You are not asserting the bug described in the title.

Back to active as the original problem is not covered by the patches.

acbramley’s picture

Getting a similar issue with a paragraph that contains a formatted text field. If a user has added a paragraph with a text format that another user doesn't have access to then if that other user tries to save a page they get The value you selected is not a valid choice., but only when the paragraph is collapsed. Clicking edit on that paragraph shows the "This field has been disabled because you do not have sufficient permissions to edit it." text area, then saving works.

Steps to reproduce:
1) Create a paragraph with a Text (formatted) field
2) Create a text format and 2 roles, one of which can't use that text format
3) Sign in as a user with the role that can access the text format (user a) and create a page with a paragraph on it with the new text format
4) Sign in as another user with the role that can't access the text format (user b) and edit the page
5) Collapse the paragraph and click save

Expected:
Page is saved

Actual:
Error message shown "The value you selected is not a valid choice."

6) Click edit on the paragraph and hit save
This works.

This same behaviour doesn't happen with the classic widget, nor with a plain core field.

berdir’s picture

That has been fixed in 8.x-1.x-dev.

acbramley’s picture

@Berdir awesome news, thanks!

handkerchief’s picture

Getting similar issue with referenced media entities. In my case paragraph is the problem.

I described the error in this issue: #3058037: Media Library can't attach media to media reference field in nodes due to AJAX problem when using table view

Core: 8.7.5
Paragraph: 8.x-1.x-dev

Error messages:
Widget Paragraph Classic:
@see https://www.drupal.org/project/drupal/issues/3058037#comment-13199839

Widget Paragraph Experimental:
An error occurs already if I click on "Add media":

"
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /en/node/16/edit?destination=/de/admin/content&ajax_form=1&_wrapper_format=drupal_ajax
StatusText: error
ResponseText: The website encountered an unexpected error. Please try again later.LogicException: Form errors cannot be set after form validation has finished. in Drupal\Core\Form\FormState->setErrorByName() (line 1057 of core/lib/Drupal/Core/Form/FormState.php). Drupal\Core\Form\FormState->setError(Array, Object) (Line: 466)
Drupal\Core\Field\WidgetBase->flagErrors(Object, Object, Array, Object) (Line: 264)
Drupal\Core\Entity\Entity\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object, Array, Object) (Line: 251)
Drupal\Core\Entity\Entity\EntityFormDisplay->validateFormValues(Object, Array, Object) (Line: 2236)
Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->massageFormValues(Array, Array, Object) (Line: 381)
Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 2296)
Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->extractFormValues(Object, Array, Object) (Line: 231)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 338)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 304)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 159)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 289)
Drupal\Core\Entity\EntityForm->submitForm(Array, Object) (Line: 149)
Drupal\Core\Entity\ContentEntityForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 590)
Drupal\Core\Form\FormBuilder->processForm('node_article_edit_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm('node_article_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 84)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
"
handkerchief’s picture

ankit agrawal’s picture

I have recently faced this issue with the media library widget used in the media field of the paragraph, got resolved after changing the widget to entity browser.

monymirza’s picture

monymirza’s picture

Status: Active » Closed (outdated)