- Issue created by @Nicolas S.
- Status changed to Needs review
about 1 year ago 2:00pm 4 September 2023 - last update
about 1 year ago 178 pass, 1 fail The last submitted patch, 3: 3385177-add-paragraphs-ids.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- Status changed to Needs work
about 1 year ago 2:27pm 4 September 2023 - 🇩🇪Germany thomaswalther Rhein-Main Area
May it will a problem with an HTML attribute "ID" from a paragraph library item?
On a page, there could be multiple referenced paragraphs, but HTML websites only allow having 1 element with the same ID.Maybe instead of attribute "id" use "data-id" or a class like "paragraph-id-123"?
- 🇮🇹Italy dgsiegel
I don't think adding arbitrary text to the paragraphs module is the way to go here. But having the ID or even the UUID available makes very much sense. I've added a small patch that exposes both the ID as well as the UUID to the paragraph widget. This allows you to access both and change the summary as you see fit, for example:
function mymodule_field_widget_single_element_paragraphs_form_alter(array &$element, \Drupal\Core\Form\FormStateInterface $form_state, array $context) { if (!empty($element['#paragraph_id']))) { $element['top']['type']['label']['#markup'] .= " <span>(#{$element['#paragraph_id']})</span>"; } }
Please note that when adding a new paragraph to a node, it will have a UUID, but not a ID. The ID will only be created once you save the node and attach the paragraph to it.