Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Jan 2016 at 15:14 UTC
Updated:
13 Sep 2023 at 11:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bojanz commentedThis patch fixes the issue. It received a sanity check by dawehner. Needs tests.
Comment #3
dawehnerLet's ensure we won't forget tests ...
Comment #4
bojanz commentedTest plan:
Implement a dummy views form handler which outputs a button, which when clicked outputs a message containing the first views argument.
Create a view that accepts an argument and contains the button handler.
Embed the view twice.
Ensure that clicking the button on the second view gives the correct message (instead of activating the first view).
Comment #5
vasikeThere is an update of the patch using Bojan's suggestions
adding some code for testing
- New Views form field plugin/hanlder
- New test view to be used, it uses this Views form field and Global null argument (fixed)
- New Route for the testing page using:
- New controller to build page with the defined view embeded twice
- New Views test to operate on the page built - incomplete.
It seems there is an issue to have Views forms in the page - the page is built without forms - content only.
So it needs work.
Maybe we need to update also the issue status.
Comment #6
mglamanHere's an interdiff between #1 and #5.
Comment #7
dawehnerIs it just me that $view_args instead of $view_arguments is a bit annoying?
I'm curious whether we should just go with twice the same block on the same page? This would save a bunch of the code here
Comment #8
mglamanWorking on this. Looks like we were missing the following from the test, so that the custom field plugin is discovered
Comment #9
mglamanThe view is now rendering the test buttons on each row and a save button for each view. Just need to write interactions.
Comment #11
mglamanHere we go, test now runs and ensures each submit button runs its appropriate form.
Comment #12
mglamanComment #13
mglamanPer #7, going to rename variable and instead of using custom page, place as blocks on homepage.
Comment #14
vasike@mglaman i can confirm that the #11 patch works.
But the "confirmation" text should be the message provided by the button submission not a custom text.
Comment #15
mglamanCould you elaborate? It is checking the message set by the button. The message says the view ID, display, and the row index. We then check for that.
Currently simpletest, as far as I could see, only allows specifying a form ID and not specific button. I added row index so we could hopefully actually test that in future.
Comment #16
mglamandawehner, I started working on placing the blocks. However, it doesn't seem we can pass view arguments through a block's settings, only the items per page. I've left the page controller as it is since the block option does not seem feasible yet.
Comment #17
bojanz commentedAgreed, keep the page. +1 to RTBC.
Comment #18
dawehnerFair point.
Comment #20
mglaman? Bot says test fail but results show different ¿
Comment #21
catchThis needs a change record for the constructor change to ViewsForm.
While it's a genuine bug fix, it's changing some @internal API surface, so moving to 8.1.x first. If this is blocking a stable Drupal Commerce release we'll need to think about a patch-release-safe way to do it in 8.0.x.
Comment #23
catch@bojanz pinged me in irc. In this case we don't expect anyone to call the constructor directly or override - this isn't a service. So we shouldn't do a change record because it's not something we're expecting people to have to update for. However the theoretical chance that someone might means it's still a default 8.1.x-only change unless we really, really can't wait (and then we might need to change the patch a bit).
Comment #24
alexpottAren't form IDs changing doesn't this mean that potential custom code that altered one of this forms would have to change? Is that not worth a CR?
Comment #25
catchThat's a good point.
Also it's a bit worse than that - hook_form_FORM_ID_alter() would have been usable before, but won't be now because the arguments change. Unless we can somehow make hook_form_BASE_FORM_ID_alter() work but this isn't using hook_forms() at all.
Comment #26
mglamanI'll work on the CR as noted in #24.
In regards to #25, I'll see how we can preserve the original form ID for
hook_form_BASE_FORM_ID_alter. We just need to stuff it into the build info.From \Drupal\Core\Form\FormBuilderInterface::prepareForm()
EDIT: By adding the form ID without arguments (as it is now) in the base form ID, no existing code should be broken.
Comment #27
mglamanHere is an updated patch. This adds a base form ID so that existing hooks work as expected, but the form ID is unique based on arguements.
Here is change record draft: https://www.drupal.org/node/2664936
Comment #28
mglamanArg, forgot to change status!
Comment #29
bojanz commentedGreat job!
Comment #30
tim.plunkettDon't we need tests for that last change, and to ensure it fixes #25?
Comment #31
catchYes I think we do, that would have been a proper API break and we very nearly missed it.
Comment #32
mglamanHere is a test that addresses #30 and #31
Comment #34
mglamanNot sure what I did to roll such a borked patch. Here is proper one.
Comment #35
dawehnerThanks a lot. We now have a test to ensure we don't break existing hook_form_alter() implementations.
Comment #37
catchThat's great. Committed/pushed to 8.1.x, thanks!
Comment #38
bojanz commentedI feel that this fix is safe for 8.0.x as well, especially now that the base form id is kept the same.
Comment #40
bojanz commented8.1 is in beta, so pushing this into 8.0 doesn't really matter anymore.
Comment #42
quietone commentedpublished change record.