diff --git a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php index 2514da5275257210d4989979c4260254208bde62..3e4417fcc1b37feda573c1a714c945dadec94f01 100644 --- a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php +++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php @@ -2304,7 +2304,29 @@ class ParagraphsWidget extends WidgetBase { continue; } - $form_state->setError($element[$item['_original_delta']], $this->t('Validation error on collapsed paragraph @path: @message', ['@path' => $violation->getPropertyPath(), '@message' => $violation->getMessage()])); + $property_data = explode('.', $violation->getPropertyPath()); + $paragraph_label = \Drupal::entityTypeManager() + ->getStorage($paragraphs_entity->getEntityTypeId() . 's_type') + ->load($paragraphs_entity->bundle()) + ->label(); + if ($property_data[0]) { + $form_state->setError($element[$item['_original_delta']], $this->t('@message (@field_name » @paragraph_label [@delta] » @nested_field_name [@nested_delta])', [ + '@message' => $violation->getMessage(), + '@field_name' => $element['#title'], + '@delta' => $item['_original_delta'] + 1, + '@paragraph_label' => $paragraph_label, + '@nested_field_name' => $paragraphs_entity->getFieldDefinition($property_data[0])->getLabel(), + '@nested_delta' => isset($property_data[1]) ? $property_data[1] + 1 : 1, + ])); + } + else { + $form_state->setError($element[$item['_original_delta']], $this->t('@message (@field_name » @paragraph_label [@delta]', [ + '@message' => $violation->getMessage(), + '@field_name' => $element['#title'], + '@delta' => $item['_original_delta'] + 1, + '@paragraph_label' => $paragraph_label, + ])); + } } } }