This module should disallow adding more than the allowed amount of paragraph items in the add widget

Created on 16 October 2019, about 5 years ago
Updated 9 September 2024, 2 months ago

Thanks for this module.

Right now this module works with a validation error if 1 item of a paragraph is allowed but 2 are added.

A maximum of 1 "Paragraph" of type "text" is allowed.

Though it would be way better for the user experience that the specified paragraph entity can be added only once and will be removed from the "add paragraph" form after this.

Many users will add more paragraphs of that type and will be disturbed by the validation error.

The problem for this feature would be to support different form items by the classic and experimental widget and allowing 3rd party tools such as paragraphs browser to hook in.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany demonde

Live updates comments and jobs are added and updated live.
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.

  • First commit to issue fork.
  • 🇷🇴Romania stefan.butura

    Patch based on #4. Fixed an error appearing when there are no paragraphs of a specific type and removed comments.

  • 🇧🇪Belgium fernly

    I can confirm patch #11 is not working when you use a modal (paragraphs stable widget) to add a paragraph.
    I'm looking in to this. I think it sucks when an editor puts in all the effort to build up a page to see tons of errors when saving.

  • Status changed to Needs review 8 months ago
  • 🇧🇪Belgium fernly

    I fixed the patch to work with the Paragraphs (stable) widget and Drupal 10. The latter can be tricky because this module supports multiple Drupal versions. However, the used hook hook_field_widget_complete_WIDGET_TYPE_form_alter is a new one for Drupal 10 only and replaces hook_field_widget_multivalue_WIDGET_TYPE_form_alter().

    So if older Drupal versions need to be supported, the hook hook_field_widget_multivalue_WIDGET_TYPE_form_alter() needs to be added again as well, containing the same code.

    Note that this patch was not written for the legacy paragraphs widget. I haven't tested that.

  • Status changed to Needs work 4 months ago
  • 🇨🇦Canada pavlosdan

    Looks like this hook exists for Drupal 9 as well so we should be good in that regard: https://api.drupal.org/api/drupal/core%21modules%21field%21field.api.php... (at least it exists for 9.5).

    I've removed support for D8 given its EOL and paragraphs dropping it as well.

    I've tested the patch with all the edit modes that the "Paragraphs (stable)" widget has and it looks like it works as advertised. Thanks a lot for driving this forward!

    Setting this back to needs work to see if we can get this working for the legacy widget as well.

  • Status changed to Needs review 4 months ago
  • 🇨🇦Canada pavlosdan

    Looks like the same code works for the legacy widget as well and we just needed the extra hook for that one. Setting this back to needs review.

    • pavlosdan committed 1c002c9a on 8.x-1.x
      Issue #3088250 by pavlosdan, Fernly, jlblanco, stefan.butura, demonde:...
  • Status changed to Fixed 3 months ago
  • 🇨🇦Canada pavlosdan

    Merged. Thanks all.

  • 🇩🇪Germany demonde

    Great, thanks!

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

Production build 0.71.5 2024