When enabling readonly module, I get the following error when visiting pages where the forms have been disabled:
The website encountered an unexpected error. Please try again later. TypeError: Argument 1 passed to Drupal\Core\Render\Element::children() must be of the type array, null given, called in /var/www/docroot/themes/contrib/thunder_admin/thunder_admin.theme on line 259
Readonly removes all the form elements, so it technically is receiving NULL instead of an array.
Wrapping that foreach() with a sanity check of if (isset($form[$field_name]['widget']) && is_array(($form[$field_name]['widget']))) {
seems to do the trick.
Comment | File | Size | Author |
---|---|---|---|
#2 | add-sanity-check-on-thunder-admin-field-3111487-1.patch | 979 bytes | jnicola |
Comments
Comment #2
jnicola CreditAttribution: jnicola at Oregon Health & Science University (OHSU) commentedComment #3
jnicola CreditAttribution: jnicola at Oregon Health & Science University (OHSU) commentedComment #4
volkerk CreditAttribution: volkerk at Thunder commentedI think the module should not unset these elements, this will probably trigger errors in other places as well.
Instead of unsetting children elements
unset($form[$key]);
, as its done in the source, it might be a good idea to deny accessform[$key]['#access'] = FALSE;
instead.Comment #5
jnicola CreditAttribution: jnicola at Oregon Health & Science University (OHSU) commentedSo I haven't found it causing a problem anywhere else, just here.
Also, I think creating code that goes through all forms and finds all elements and disables all of them is arduous by comparison to a little sanity check here.
Comment #6
volkerk CreditAttribution: volkerk at Thunder commentedComment #7
volkerk CreditAttribution: volkerk at Thunder commentedWell fine, that check won't hurt.
https://github.com/BurdaMagazinOrg/theme-thunder-admin/pull/285
Comment #10
volkerk CreditAttribution: volkerk at Thunder commented