Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
views.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 May 2013 at 18:12 UTC
Updated:
25 Dec 2014 at 23:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tim.plunkettComment #2
dave reidI have a feeling that Views will not be alone in the need for this, so I added a general drupal_rewrite_states_selector() helper function.
Included is a patch that can be used to test this by adding a #states on image formatter's 'Link image to' setting being dependent on the image style being 'medium'.
Comment #3
dave reidFixing mismatch in function name call.
Comment #4
dave reidIt actually would be nice for forms to be able to pass into the field formatter settings form what the 'base' element is named, but I think this is a good solution for now. Tim said some more inline documentation is necessary.
Comment #5
dawehnerThat's a great idea!
I guess we would also need some test for this new function.
Comment #6
dave reidIdeas on how to test this or a pointer to an existing test that hits some of the same code would be welcome.
Comment #7
dawehner#3: 1985406-views-field-formatter-settings-states.patch queued for re-testing.
Comment #8
jhedstromRe-rolled the above solution, but would this make more sense in a component somewhere?
Comment #9
dawehnerI think having this there, for now, is a totally fine place ... All of the states API is still in that place.
Let's readd the tags, @jhedstrom do you mind writing a test?
Comment #11
jhedstromThis adds a very simple test (taken from Dave Reid's example).
Comment #13
jhedstromThe property
$field->idno longer exists. I've updated the patch to use$field->getLabel()instead, but am not sure that is the correct change to make.Comment #14
jhedstromThe proper method to use is
getName()(in my manual testing anyway). Theid()method includes entity and bundle info, which is not present in the markup.I've included an update to the manual testing patch.
Comment #15
jhedstromComment #16
dawehnerCool. Does someone know whether we should backport this to D7 (API addition or just directly in views)?
Comment #17
alexpottI think we might be able to leverage this code in
FilterPluginBase::buildExposedFiltersGroupForm()there is a load of code after line 988 manipulating states.Comment #18
dawehner@alexpott
So no commit of the current status which already solves a bug? your suggestion is just a task.
Comment #19
alexpottI think this should be a static method on a new FormHelper class.
Deprecated.
Once the above is done this can be a PHPUnit test.
Comment #20
alexpottAlso this will fail in the states array is declared like this:
From \Drupal\views\Plugin\views\display\Page
See #2356443: Grouped numeric filters can not have a value set for an instance of this bug - and somewhere this function should be used.
Comment #21
jhedstromThis patch moves the logic to a helper class as suggested, and has been reworked to apply to the example in #20.
I need more insight to the code in
FilterPluginBase::buildExposedFiltersGroupForm()before I feel comfortable porting it over to use this new helper method.Comment #22
alexpottLook at all the untested code we can remove! Closing #2356443: Grouped numeric filters can not have a value set in favour of this issue since this adds a tested method to do what we need. I've manually tested too and it works great.
Upgrading to major since grouped views filters can not be set up without it (if you have javascript turned on).
Steps to reproduce:
The value, min and max fields are all hidden. What is supposed to happen is that either the value or the min max fields are supposed to appear depending on which operator you have selected.
Comment #23
olli commentedThe #states can be more than two levels deep.
Without this default values are not set. The value, min and max fields are all empty when you go back to edit the grouped filter.
Comment #24
alexpottre #23
Comment #25
olli commentedSee the example in https://www.drupal.org/node/1464758
Comment #26
alexpottHow is that different from the example I pointed out in #20 and was subsequently fixed?
Comment #27
alexpottOh I see :) - patch incoming.
Comment #28
alexpottAdded https://www.drupal.org/node/1464758 as part of the test and improved
rewriteStatesSelectorto handle this. Also fixed #23.2Comment #29
olli commentedGreat!! Some notes:
"Provides helpers to operate on forms"?
Unused $ids.
$ids -> $elements
I wonder if it is possible to move these array_*() friends outside the loop.
Why the second "if"?
Since we are inside a table, would #title_display = invisible work here?
Contains core FormHelperTest.
Comment #30
alexpottComment #31
alexpottI've just scanned the whole of core and I think that FilterPluginBase is the only place we're doing this sort of manipulation of the states array so it's definitely good to covert it to the new helper method.
Comment #32
olli commented#30.6 I agree, we need to improve that anyway. I've made a small fix in this code to restore your fix to #23.2.
Comment #33
alexpottre #32 @olli nice catch - again! We so need tests!
Comment #34
jhedstromGreat work on the expanded tests! RTBC IMO.
Comment #35
olli commentedRe #33: There are tests for #23.2 in #2357145: Views can not be saved with a numeric (grouped) filter and #2369119: Fatal error when trying to save a View with grouped filters using other than string values.
Comment #39
olli commentedI only made a small change in #32 (we didn't have tests for it yet) so I guess I can set this to RTBC.
Opened #2387353: Improve form element labels in views grouped filter for #29.6
Comment #40
catchLooks like the array_combine() could happen after the foreach has run?
IDs change?
Comment #41
catchComment #42
alexpottComment #43
catchCommitted/pushed to 8.0.x, thanks!