With most designs, paragraphs have a header above them. We should add this into each type. If users don't want to use, the code should not show up.

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thejimbirch created an issue. See original summary.

thejimbirch’s picture

Assigned: Unassigned » thejimbirch

In progress

thejimbirch’s picture

Status: Active » Needs review
FileSize
56.84 KB

Attached is a big patch that:

  1. Adds the new header field
  2. Adds the field to Accordion, Blank, Block, Columns (2, 3, and Equal), Image, Modal, Simple, Tabs, and View bundles
  3. If it is an update of an existing installation, the field is added to those bundle forms, but not in the view. Admins can decide to display it or not.
  4. Updates the appropriate templates to have the new field as an H2

Some steps to validate updating:
Install dev version of Bootstrap Paragraphs (composer require drupal/bootstrap_paragraphs:2.x-dev)
Enable the module
Follow configuration instructions in README.md
Apply patch
Run updb or visit /update.php
Add some paragraphs and see they have the Header field in the form but not the display.

To validate a new install, apply the patch before enabling

mluzitano’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
74.71 KB
39.7 KB
79.21 KB

This is working as expected for me. See the attached screenshots noting the field existing in the Accordion, Blank, and Columns (Two Uneven) as examples.

  • thejimbirch committed 3233d60 on 8.x-2.x
    Issue #3040370 by thejimbirch, mluzitano: Add Headers to each Paragraph
    
thejimbirch’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in dev, thanks!

Jorge Navarro’s picture

I get this error after updating db

[notice] Update started: bootstrap_paragraphs_update_8204
>  [error]  Missing bundle entity, entity type paragraphs_type, entity id bp_modal.
>  [error]  Update failed: bootstrap_paragraphs_update_8204
 [error]  Update aborted by: bootstrap_paragraphs_update_8204
 [error]  Finished performing updates.
thejimbirch’s picture

@Jorge Navarro Do you have the Modal Paragraph type? Or did you delete it?

Jorge Navarro’s picture

Yes, deleted, ok! I've bypassed the error... maybe it should check if exists so the update does not abort.

thejimbirch’s picture

I will definitely take that into account for the next update hook I have to write, thanks!

Status: Fixed » Closed (fixed)

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

brooke_heaton’s picture

Getting this same error.

Error Output:
================
> [notice] Update started: bootstrap_paragraphs_update_8204
> [error] Missing bundle entity, entity type paragraphs_type, entity id bp_accordion.
> [error] Update failed: bootstrap_paragraphs_update_8204
> [notice] Message: Created snippet file based on configuration.

thejimbirch’s picture

Category: Feature request » Support request
Status: Closed (fixed) » Active

@brooke_heaton Do you have a paragraph bundle with the machine name bp_accordion?

johnnydarkko’s picture

@thejimbirch - Working with @brooke_heaton on this one...
There is no paragraph bundle with the machine name bp_accordion.
This error pops up in the watchdog log twice:

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: paragraph, bundle: bp_accordion, field name: bp_header

thejimbirch’s picture

Status: Active » Needs review

@johnnydarkko. Do you have an accordion with another machine name? Or did you guys delete it?

What update 8204 did was look through the Paragraph bundles and add the bp_header field.

Since the update only needs to run once, you could remove those lines from the install file, and then add them back after the update has run.

See:
https://git.drupalcode.org/project/bootstrap_paragraphs/blob/3233d60f04c...

brooke_heaton’s picture

Probably best to fix the update hook and patch. This is unfortunate.

brooke_heaton’s picture

The attached patch performs an EntityQuery on each Bootstrap Paragraph bundle that comes with the optional config and only attempts to add headers to existing entities. Because the Dev versions update made the broad assumption that paragraphs of each time exist, this resulted in continual unnecessary update failures. This patch ensures that only existing entities are updated.

brooke_heaton’s picture

FileSize
21.93 KB

Updated patch to make message reflect only the bundles updated - only bundles with entities will be updated.

brooke_heaton’s picture

FileSize
22.25 KB

Polished up the message a bit.

snable’s picture

I am not totally sure if this is directly related to the patch but when i import config (add_headers_to_each_paragraph_3040370_19.patch already applied) i get:

[error] A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: paragraph, bundle: bp_modal, field name: bp_header

Fixed the above by reimporting database and cleaning up -

However, after trying to update translatable content in a multilanguage setup i get the following error:

InvalidArgumentException: Invalid translation language (en) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (Zeile 873 in /var/www/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

This is related to all new (and by default empty) header fields added to existing entities after applying the patch. This happens only on saving the secondary language (in my case "en"). This results in a fatal error.

Can anyone reproduce that error?

Best

snable’s picture

I digged a little deeper and must confirm that the error reported in my last comment is not directly connected to the issue.
It looks like this is deeper within paragraphs itself possibly related to the unsupported translation in paragraph fields.

rovo’s picture

@brooke_heaton patch from #19 resolved my 8204 error.

Twig\Error\LoaderError: Template                                                                     
"modules/contrib/bootstrap_paragraphs/templates/field--entity-reference-revisions.html.twig" is not  
defined. in Twig\Loader\ChainLoader->getCacheKey() (line 96 of                                       
/var/www/html/web/core/modules/node/templates/node.html.twig).  
twills’s picture

Status: Needs review » Reviewed & tested by the community

Patch from comment #19 applied successfully!

thejimbirch’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies.

thejimbirch’s picture

Assigned: thejimbirch » Unassigned