Problem/Motivation
The views builds a form when it should not. If a field usually triggers views to build a form, but the format is switched to not use fields, then the form is created.
Background
DisplayPluginBase.php runs
// If form fields were found in the view, reformat the view output as a form.
if ($view->hasFormElements()) {
in core/modules/views/src/ViewExecutable.php, line 2450 function hasFormElements runs
foreach ($this->field as $field) {
if (property_exists($field, 'views_form_callback') || method_exists($field, 'viewsForm')) {
return TRUE;
}
}
Then a form is created.
How to reproduce
Reference #2855691: Display is wrap in a form and Save button is shown
Install draggableviews module then:
- Create a view with a display NOT using fields (e.g. rendered teasers)
- Create a second display that uses the table format (to be used as draggable)
The display format will have to be set for this display only, not all displays.
For: This page (override) - Add the draggableview content field, but DON'T select to override the defaults.
For: All displays
Without any external dependencies:
* Add a second page display to the content view
* Give it a path
* For the new display only: set the format to a grid
* For the new display only: set the show to content | teasers
* Visit the new page
Expected result:
The bulk action selector form isn't shown
Actual result:
The bulk action selector form is shown
Comment | File | Size | Author |
---|---|---|---|
#15 | 2917239-15.patch | 2.78 KB | Lendude |
| |||
#12 | 2917239-12-TEST_ONLY.patch | 2.05 KB | Lendude |
Comments
Comment #10
larowlanIs this still an issue?
Can you provide some screenshots or a sample view?
Comment #11
LendudeUpdated the steps to reproduce with steps that have no dependencies on other things than core.
Comment #12
LendudeTest and a fix. Since we are evaluating if $fields contains anything with a form, it makes sense to only test this if the current display actually uses fields.
Comment #14
dwwThanks for finding this and the prompt fix! Mostly looks great. 1 tiny winy nit standing between me and RTBC (points 2 and 3):
Small, obvious, clear fix for the bug. Nothing to complain about. This change is 💯 self-documenting, doesn't need a comment to see what's happening and why.
Very minor nit:
form-without-fields
seems like a slightly confusing path for this display. It's not a form at all (or shouldn't be). That's the point, right? How aboutdisplay-without-fields
or something?Cuz right here is some cognitive dissonance:
1. Get "the form".
2. Ensure there's no form.
🤔 huh? 😉
But:
1. Get "display-without-fields"
2. Ensure there's no form.
👍
Not gonna NW over this, and I'll ping in Slack for thoughts. I'm totally fine with this landing as-is, but I think a 7 character change would make it even better....
Thanks again!
-Derek
Comment #15
LendudeThanks for the feedback, agree with both points, that makes it easier to read indeed!
Comment #16
dwwSweet, thanks! Just added a notification for that bot run. When I get the email that it's green, I'll RTBC. Thanks again!
Comment #17
dww🎉
Comment #19
dwwRandom QE fail. Back to RTBC.
Comment #20
larowlanQueued a 10.x test run
Comment #22
larowlanCommitted to 10.0.x
Backported to 9.5.x, 9.4.x and 9.3.x 😌
Thanks folks 🚀