Skip to content
Snippets Groups Projects

Issue #3247185: Media library field is required when it is not accesible

1 file
+ 4
2
Compare changes
  • Side-by-side
  • Inline
@@ -1003,8 +1003,10 @@ protected static function setFieldState(array $element, FormStateInterface $form
* The form array.
*/
public static function validateRequired(array $element, FormStateInterface $form_state, array $form) {
// If a remove button triggered submit, this validation isn't needed.
if (in_array([static::class, 'removeItem'], $form_state->getSubmitHandlers(), TRUE)) {
// If a remove button triggered submit, or the element is not accessible,
// this validation isn't needed.
if ((isset($element['selection']['#access']) && !$element['selection']['#access']) ||
in_array([static::class, 'removeItem'], $form_state->getSubmitHandlers(), TRUE)) {
return;
}
Loading