I don't know if this is a general error or if it only happens in our implementation and configuration, but we ran into an issue when using this workaround. Saving sections with paragraphs works fine, but when we try to edit the saved paragraphs, ValidReferenceConstraintValidator throws an error saying, "This entity (paragraph: XXXXXX) cannot be referenced."
I don't have a certain answer why (I'm not a Drupal or PHP dev as such; I'm just tasked with making this work), but I think it's because of the way these paragraphs in Layout Paragraphs are referenced. My workaround for the issue was to use hook_validation_constraint_alter to replace this validator with a copy of it where I can skip if the paragraph is a section_wrapper. Everything is working fine if I do this.
function [MODULE]_validation_constraint_alter(array &$definitions) {
$definitions["ValidReference"]['class'] = "Drupal\drupal_cms_validators\Plugin\Validation\Constraint\ValidReferenceConstraint";
}
It might be important to note that we only want the sections added to the library because we want to limit which paragraph types can be added to specific areas. We use a module called layout_paragraphs_limit to achieve this.
Did anyone else experience this problem? Is there a better way of fixing it?
I don't know if this is a general error or if it only happens in our implementation and configuration, but we ran into an issue when using this workaround. Saving sections with paragraphs works fine, but when we try to edit the saved paragraphs, ValidReferenceConstraintValidator throws an error saying, "This entity (paragraph: XXXXXX) cannot be referenced."
I don't have a certain answer why (I'm not a Drupal or PHP dev as such; I'm just tasked with making this work), but I think it's because of the way these paragraphs in Layout Paragraphs are referenced. My workaround for the issue was to use hook_validation_constraint_alter to replace this validator with a copy of it where I can skip if the paragraph is a section_wrapper. Everything is working fine if I do this.
function [MODULE]_validation_constraint_alter(array &$definitions) {
$definitions["ValidReference"]['class'] = "Drupal\drupal_cms_validators\Plugin\Validation\Constraint\ValidReferenceConstraint";
}
It might be important to note that we only want the sections added to the library because we want to limit which paragraph types can be added to specific areas. We use a module called layout_paragraphs_limit to achieve this.
Did anyone else experience this problem? Is there a better way of fixing it?