- Issue created by @solideogloria
- Assigned to abhishek_virasat
- Issue was unassigned.
- Status changed to Postponed: needs info
3 months ago 7:12pm 4 April 2024 - 🇺🇸United States jrockowitz Brooklyn, NY
My best guess is one of your webforms is triggering the error because an element is missing a #format property.
I can't reproduce this error using the attached webform.
Can you determine which webform or element is triggering this error?
- Status changed to Active
3 months ago 7:35pm 4 April 2024 It can happen if an element doesn't have any formats that are allowed.
// Get a list of formats that the current user has access to. $formats = filter_formats($user); // Allow the list of formats to be restricted. if (isset($element['#allowed_formats'])) { // We do not add the fallback format here to allow the use-case of forcing // certain text formats to be used for certain text areas. In case the // fallback format is supposed to be allowed as well, it must be added to // $element['#allowed_formats'] explicitly. $formats = array_intersect_key($formats, array_flip($element['#allowed_formats'])); } // `$formats` IS EMPTY HERE. if (!isset($element['#format']) && !empty($formats)) { // If no text format was selected, use the allowed format with the highest // weight. This is equivalent to calling filter_default_format(). $element['#format'] = reset($formats)->id(); } // ... later on, `$element['#format']` is accessed, but it hasn't been set.
- 🇺🇸United States jrockowitz Brooklyn, NY
Maybe we need to also support a default format
Plain text could be added in if it's available. Though it can't be deleted in the UI and it automatically is useable by all users (including Anonymous), its config file could probably be removed. Removing it would probably break some things, but I'm not sure if it can be relied upon to exist.
- 🇺🇸United States jrockowitz Brooklyn, NY
The attached webform replicates the issue when the form is view as an anonymous user.
- Merge request !438Issue #3437894: Undefined array key "#format" in... → (Merged) created by jrockowitz
- Status changed to Needs review
3 months ago 3:21pm 5 April 2024 - last update
3 months ago 536 pass What happens if the user's default format is more privileged than any of the allowed formats?
- last update
3 months ago 536 pass - last update
3 months ago 536 pass - 🇺🇸United States jrockowitz Brooklyn, NY
Let's add the below code to disable the input/element.
// Set the #format to empty string to disable the text format. $element['#format'] = '';
- Status changed to Needs work
3 months ago 7:05pm 5 April 2024 Other than needing to use the injected current user, it does fix the warnings when running the command.
- last update
3 months ago 536 pass - Status changed to Needs review
3 months ago 1:07am 6 April 2024 - last update
3 months ago 536 pass -
jrockowitz →
committed e1ef1927 on 6.2.x
Issue #3437894: Undefined array key "#format" in...
-
jrockowitz →
committed e1ef1927 on 6.2.x
- Status changed to Fixed
3 months ago 2:59am 8 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.