To reproduce:

  • 1. Install Drupal with the standard profile, so there's an article node type with an image field
  • 2. Add this implementation of hook_entity_field_access() to a custom module:
/**
 * Implements hook_entity_field_access().
 */
function MYMODULE_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, \Drupal\Core\Session\AccountInterface $account, \Drupal\Core\Field\FieldItemListInterface $items = NULL) {
  if ($field_definition->getName() == 'field_image' && $operation == 'edit') {
    return \Drupal\Core\Access\AccessResult::forbidden();
  }
}
  • 3. Create a new article node

The image field is hidden in the article form, as expected. However, on saving, there is this error message:

Warning: array_key_exists() expects parameter 2 to be array, null given in Drupal\svg_image\Plugin\Field\FieldWidget\SvgImageWidget::validateRequiredFields() (line 324 of core/modules/contrib/svgimage/src/Plugin/Field/FieldWidget/SvgImageWidget.php).

Comments

jkuma created an issue. See original summary.

jkuma’s picture

Hello,

Here is an attempt to solve this issue, it's based on what have been done by alexpott on #2715859.

jkuma’s picture

Status: Active » Needs review
sokru’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

mxr576’s picture

LGTM

imyaro’s picture

Assigned: Unassigned » imyaro

  • zvse committed 4633aba on 8.x-1.x
    Issue #3026270 by jkuma, zvse: SvgImageWidget::validateRequiredFields()...
imyaro’s picture

Status: Reviewed & tested by the community » Fixed

Patch modified and commited. Thank you

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.