- Issue created by @forward-media
- 007e84d0 committed on 2.0.x
Issue #3532248 by forward-media, flocondetoile: Warning: Undefined array...
- 007e84d0 committed on 2.0.x
I'm encountering the following warning when saving an entity that uses the Protected File field type:
Warning: Undefined array key "protected_file" in Drupal\protected_file\Plugin\Field\FieldWidget\ProtectedFileWidget::process() (line 88 of modules/contrib/protected_file/src/Plugin/Field/FieldWidget/ProtectedFileWidget.php)
This happens when the widget attempts to access $item['protected_file'], but the key doesn't exist for all items.
Use a safer fallback to avoid the warning:
'#value' => (isset($item['protected_file']) && $item['protected_file']) ? 1 : 0,
This avoids accessing undefined array keys and prevents unnecessary PHP warnings.
Drupal 9.5.11
PHP 8.1.32
Active
1.5
User interface
Issue #3532248 by forward-media, flocondetoile: Warning: Undefined array...