- Issue created by @Shashwat Purav
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 8:39am 25 February 2023 - 🇮🇳India Shashwat Purav Mumbai
Added patch to add validation to check if $field and $field_output are not empty.
- Status changed to Postponed: needs info
over 1 year ago 12:15pm 27 February 2023 - 🇫🇷France Grimreaper France 🇫🇷
Hello,
To understand the condition of the error, can you share your pattern YAML and Twig template please?
- Status changed to Needs review
about 1 year ago 1:36pm 21 September 2023 - 🇧🇪Belgium Steven Dullaert
We had this same issue, and after quite a bit of detective work I've figured out what caused it (in our case).
Our situation:
We have a "Content select" view (which is used by an entity browser to add page teasers in a layout builder block via entity reference field). This view has a display, lets call it "Display A", that uses a 'Card' pattern for it's row display, and has the following fields, mapped to the pattern.- Content: Entity browser bulk select form
- Content: Featured image (field_featured_image)
- Content: Title
- Content: Teaser
After a colleague recently added a new display "Display B" to this view, our initial Display A no longer worked. When the entity browser modal was opened, the above error would be shown in the modal.
Display B is a copy of Display A, but includes a new field, Content: Image (field_image) which was specifically added only to this display, because it lists a content type that doesn't use field_featured_image.
However, when checking with xdebug, if found out that when Display A was displayed, the foreach at line 42 of ui_patterns/modules/ui_patterns_views/ui_patterns_views.module also included field_image as one of the fields. Since that field does not exist on this display, which results in the error.
However, reviewing the pattern mapping of the row display via the Views UI showed nothing wrong. There was no mention of field_image, or any mapping for it. And it wasn't mentioned in the Default display either.
So what was wrong? It took a while to figure out, but this is where the problem lies:
When the new display was created, and the new field was added to it, my colleague mapped field_image to a region in the pattern in the settings of the Pattern row display. However, he did not set the row display itself to the "this display override", so the mapping of field_image to the pattern region was saved for "All displays".
Visually, in views UI, each display's row settings seem fine (because in Display A, field_image is not show as an option to map to the pattern), but the mapping still exists for that display because it was saved to the defaults for the whole view.
So to reproduce:
- Create content type A with field X
- Create content type B with field X and Y
- Create a view.
- Make a display, that lists content type A, and set it rows style to pattern, and map field X to one of the regions in the settings.
- Clone the display, make it list content type B, add field Y as an override for that display's fields. Go to the row style settings, and map field Y to one of the regions of the patterns. (Make sure not to make that an override, but keep it for all displays"
- Visit the first view, it should throw the error.
The patch in #2 fixes the error preventing the view from being displayed, but will still throw the following warning:
Warning: Undefined array key "field_image" in template_preprocess_pattern_views_row() (line 44 of modules/contrib/ui_patterns/modules/ui_patterns_views/ui_patterns_views.module).
- Status changed to Needs work
about 1 year ago 1:41pm 21 September 2023 - First commit to issue fork.
- Status changed to Needs review
about 1 year ago 6:01pm 30 September 2023 - last update
about 1 year ago 86 pass - 🇮🇳India RiyaDongre
Modified the patch and added a condition to see if the field is available in the current display. Please review.
- 🇮🇳India RiyaDongre
Here's adding an interdiff for your reference, that contains the condition applied in the patch.
- Assigned to Grimreaper
- Merge request !56Issue #3344405 by RiyaDongre, Shashwat Purav, steven.d, pdureau, Grimreaper:... → (Merged) created by Grimreaper
- last update
10 months ago CI error - 🇫🇷France Grimreaper France 🇫🇷
@steven.d thanks a lot for the detailed steps to reproduce.
Confirming I am able to reproduce and that the proposed fix avoid the fatal error but a warning remains so I have simplified the check and made a PR.
- last update
10 months ago 82 pass, 4 fail -
Grimreaper →
committed dde3a0fd on 8.x-1.x authored by
steven.d →
Issue #3344405 by RiyaDongre, Shashwat Purav, steven.d, pdureau,...
-
Grimreaper →
committed dde3a0fd on 8.x-1.x authored by
steven.d →
- Issue was unassigned.
- Status changed to Fixed
10 months ago 8:33am 26 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.