Skip to content
Snippets Groups Projects

Issue #3508822: Property constraints validation adding errors to the field element instead of just the property

Closed Issue #3508822: Property constraints validation adding errors to the field element instead of just the property
1 unresolved thread
1 unresolved thread
Files
7
@@ -12,6 +12,7 @@
use Drupal\file\Entity\File;
use Drupal\file\Plugin\Field\FieldWidget\FileWidget;
use Drupal\image\Entity\ImageStyle;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
* Plugin implementation of the 'image_image' widget.
@@ -344,4 +345,14 @@ public function onDependencyRemoval(array $dependencies) {
return $changed;
}
/**
* {@inheritdoc}
*/
public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) {
$element = parent::errorElement($element, $error, $form, $form_state);
$property_path_array = explode('.', $error->getPropertyPath());
return ($element === FALSE) ? FALSE : $element[$property_path_array[1]];
}
}
Loading