Skip to content
Snippets Groups Projects

Port the WebformElementValidationPattern type to GraphQL 4.

12 files
+ 142
165
Compare changes
  • Side-by-side
  • Inline
Files
12
@@ -31,10 +31,6 @@ use Symfony\Component\String\UnicodeString;
* "type" = @ContextDefinition("string",
* label = @Translation("The desired type."),
* required = FALSE
* ),
* "default" = @ContextDefinition("string",
* label = @Translation("Default value"),
* required = FALSE
* )
* }
* )
@@ -92,18 +88,16 @@ class WebformElementProperty extends DataProducerPluginBase implements Container
// from PascalCase to snake_case.
$property = (new UnicodeString($property))->snake()->toString();
// Try to get the value from the element directly.
// If this is an element with multiple values, inspect the first actual
// element instead of the wrapper which is a fieldset or container.
if ($element['#type'] === 'webform_multiple' && !empty($element['items'][0]['_item_'])) {
$element = $element['items'][0]['_item_'];
}
$plugin = $this->elementManager->getElementInstance($element);
$value = $plugin->getElementProperty($element, $property);
// If we didn't find the value and this is an element with multiple values,
// we are looking inside the wrapper. Try getting the value from the first
// actual element instead.
if ($value === NULL && $element['#type'] === 'webform_multiple' && !empty($element['items'][0]['_item_'])) {
$value = $plugin->getElementProperty($element['items'][0]['_item_'], $property);
}
// If it's still not there, fall back to the "decoded" values. This is the
// If we didn't find a value, fall back to the "decoded" values. This is the
// case for the "#description" field, which Webform removes from the
// element.
// @todo Check if this is actually necessary.
Loading