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
Comment #2
jkuma commentedHello,
Here is an attempt to solve this issue, it's based on what have been done by alexpott on #2715859.
Comment #3
jkuma commentedComment #4
sokru commentedLooks good.
Comment #5
mxr576LGTM
Comment #6
imyaro commentedComment #8
imyaro commentedPatch modified and commited. Thank you