Questions tagged as ['paragraphs']
We have a site that after a few years has built up 10 million records in the paragraphs_item table. This is a result of lots of data migrations (where paragraphs are involved) and there are many orphans now (probably 90% of that).
Entity Reference Revisions ships with a Drush command now to 'purge' orphaned entities. This does appear to work - but with this many to look through it seems like it w ...
I'm on D9 and I've a paragraph inside a content type node.
I need to hook when the paragraph is deleted to do some custom logic and set up a queue.
I've tried hook_entity_delete
, hook_entity_predelete
or hook_paragraph_delete
, hook_paragraph_predelete
: those hooks run during cron, if the node containing the paragraph is deleted.
However, it seems to me those aren't triggered if an existing paragraph ...
I have a paragraph type with 2 fields: year and quarter
I have a content type with a paragraph field (field_year_and_quarter
) targeting ONLY this paragraph type
I am trying to create a constraint to disallow the encoding of a duplicate (same year/quarter)
I have tried:
1-A constraint at the node level which is looping into field_year_and_quarter
with $node->get('field_year_and_quarter')->reference ...
This is what I have:
I have three twig files:
- block--paragraph-images.html.twig (which extends block.html.twig)
- field--field-paragraph-image-block.html.twig (the paragraph field which is located in the custom block type, block--paragraph-images.html.twig.)
- paragraph--field-paragraph-image.html.twig (which houses three fields: field_paragraph_image, field_paragraph_title, and field_paragraph_text ...
Working with an older D7 site. On it, we have added the latest version of Paragraphs to add some content items to a page. This all works fine.
However, when trying to remove a Paragraph Item from the form, you get an AJAX error. The root of it is:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 8006 of /mnt/www/html/moswebsandbox1/docroot/include ...

I am currently a caretaker for a Drupal 7 website and I can't figure out how to group paragraph items in views. I have created a content type Products and one of the fields is called product variation which is field type paragraphs. I have created a paragraph bundle for that field.
Then I created a view to show the products on the front page. To display the paragraph fields I created a content re ...
This is a bit convoluted; so hopefully it makes sense:
I have a parent entity: Event. Event has a Paragraph field on it: Sessions (paragraph type: Session).
I use Layout Builder to format the Full Content view mode of the Event. In the layout I add a (paragraph) view which lists the Session paragraphs as Teasers (view mode of Session) with a contextual filter of Paragraph: Parent ID. This all works ...
I'm trying to get the number of paragraphs an authenticated user inputs by counting them in the parent block template and trying to access that number in the paragraphs template. I have two templates I'm working with:
- field--field-hover-image-block.html.twig
- paragraph--hover-images.html.twig
The paragraphs are being loaded through the paragraph entity field in a custom block. I'm counting the numb ...
I am validating a multi value paragraph field using constraints.
/**
* Implements hook_entity_bundle_field_info_alter().
*/
function cnfpt_internet_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
if ($bundle === 'manifestation') {
if (isset($fields['field_occurence'])) {
// Add a validation.
$fields['field_occurence'] ...
I am using constraint for the validation my multi value paragraph field.
I can correctly implement the different validation rules but I haven't found out how to highlight only the erroneous field(s).
Here is my violation declaration
$this->context
->buildViolation($constraint->modaliteRequise)
->atPath((string) $delta . 'subform.field_modalite.0')
->addViolation( ...
I created a select custom field that must be inserted inside a paragraph and the options values are dynamically inserted based on another reference field present in the paragraph itself. How can I access the actual paragraph instance to read the value of the reference field, so I can manage the right values inside the formElement function of the custom field?
I'm using a multiple paragraphs field on a node.
I noticed that each time I saved the node and then edited it again, the last item (delta n-1 with delta starting at 0) would disappear. If I clicked on the Add new button, it would repopulate with the content of the missing field. However, if I saved without taking any further action, the next last field would disappear.
I dug around in the module code, ...

For our new Drupal 9 (or 8 if necc.) website we require a very fine controllable access structure where we can give and restrict access on a user by user basis. Not only for a content type but also for the paragraphs (or more atomic components of a page). With Tac Lite we can already set the permission via taxonomy terms on a user bases to view a node. But now we would like to also controll single parag ...
I'm writing a twig template for a paragraph. I'd like to access a text field value from the page/node where this type of paragraph will be added.
Specifically, I'd like to access the value of a text field titled 'field_runner_id'. I access this value in my page/node twig template like this:
content.field_runner_id|field_value
I've tried a handful of techniques (listed below) to access that field value wi ...

My Content Type has a Paragraphs field that is Not required. The Paragraph type has a required field for when it is added, but until it is added, this shouldn't trigger "required" for my field. Since my field only has 1 paragraph type option, it is ALWAYS added! I can Remove the paragraph from the field, and required doesn't get triggered. But every time the form loads to add a new node, it always adds ...
For reference:
-modules
--contrib
---ds
--custom
---ds
I'm looking to add paragraph layouts using flexbox. I don't see a module specifically for this, so I realize I'm going to have to adapt an existing module.
Right now, I'm trying to add custom layouts in the Display Suite module by adding a template config to ds.layouts.twig with the appropriate html.twig and css files.
My concern is that any e ...
I have a webform (contact_info) which is attached to a paragraph's field (field_contact_info). The paragraph has other fields as well.
I implemented hook_form_alter()
to change some attributes inside the webform's form.
Is there any way to access the values of other paragraph fields value in hook_form_alter()
?
I can pass them inside the webform object, but those aren't available in hook_form_alter()
I'm making a headless Drupal site with Gatsby using paragraphs. I'm experienced with Drupal but relatively new with gatsby/graphql.
The issue I'm running into is that if our database does not actually have any instances of a paragraph, then it generates the schema without that (i guess it generates a minimal schema based on what exists, not what types are actually possible) and it errors out beca ...

I have this strange behaviour on my local drupal9 instance. I start it in the web
folder with the build in php development server: php -S localhost:8000
Now if I try to edit any paragraphs field, eg. /admin/structure/paragraphs_type/manual_news/fields/paragraph.manual_news.field_news_entries
[Fri Aug 13 12:47:39 2021] 127.0.0.1:55544 [404]: POST /admin/structure/paragraphs_type/manual_news/fields/paragra ...
I'm following this guide https://drupal.stackexchange.com/a/277898/56676 which I found very useful. So, I understand where the first function goes, but when it comes to the method public function getArgument()
, I'm not sure where this function should be included?
Considering that we don't have a custom widget, we are using entity browser in configuration.
So, do we need to create custom widget, plu ...

I have a paragraph type with a node ref field that, if you leave it empty, is supposed to show a random node using some defined logic.
I have the code to do the query and get the node, and ideally I'd want to put it on the paragraph object in some pre-render hook so that the paragraph can render normally using its usual config. Something like this (warning: pseudo-codish):
function mymodule_paragraph_ ...
I want to add configuration settings to Paragraph entities in a specific bundle in Drupal 8. Theres potentially a lot of options and the need to change/update them over time, so I figure the best way is through ThirdPartySettings and not adding more fields to it. I am going to use these values to influence certain aspects of the render and for search queries.
I can see where you can add settings ...
Using the linked_field module and the [paragraph:field_pbpresentation_file:entity:url] token, I get the edit link for the media entity, not the link to download the file itself.
What token should I use for the download link?
I have two content types (ContentA, ContentB) which both use the same paragraph (MyParagraph) as field type “Entity reference revisions.”
MyParagraph consists of two “List (text)” fields: ParagraphFieldA, ParagraphFieldB.
The values for ParagraphFieldA and ParagraphFieldB come in both cases from allowed values lists which have a key and label.
ContentA is limited to one MyParagraph reference bu ...
I already added the Check in/out History field to the user account, which has the check-in date and check-out date fields.
How can I programmatically add new items to Check in/out History?
I need to create some history for users.
Check-in date | Check-out date |
---|---|
04/05/21 | 05/07/21 |
03/05/20 | 04/14/20 |
I have a Course content type which has several "modules." (A module is just a name.) There are also several "units," which may or not belong to a module. A unit has several fields, for example Location, Description.
I have created a Course unit paragraph type, and a Units field in the "course" content type, which references this paragraph type. That way I can create units that belong to the course.
I have a wrapper paragraph, Layout (para_layout), which has the following fields.
I created the same paragraphs and field structure in a Drupal 9 website. I created the following custom migration plugin.
id: custom_para1
label: Custom paragraph migration
migration_group: custom
migration_tags:
- node
source:
plugin: d7_paragraphs_item
bundle: para_layout
process:
field_left_column: fie ...