Drupal 8:
I am altering a view using hook_views_data_alter to display a date range filter.
I was able to create the form to look the way I wanted with hook_form_alter.
It looks like this:
Start Date: (textfield, the value of which is a filter)
End Date: (textfield, the value of which is a filter)
Now, this works and it filters successfully. What I'm having a hard time with, though, is a pair of radio buttons I'm generating in hook_form_alter.
I have two radio buttons. One says 'Date Range', and the other says 'Show All'. I want, when the user has selected 'Show All', for the date range filter to be ignored when the user clicks 'Submit'.
I know there's removeHandler(), but where can I call this? I tried calling it in hook_views_pre_build(), but it doesn't appear to do anything. Any help would be greatly appreciated!
Comments
I am facing a similar issue.
I am facing a similar issue. I am able to remove a filter, but am unable to acces other filter data in
hook_views_pre_build()
. I created a question on Drupal Answers: http://drupal.stackexchange.com/questions/171331/remove-filter-from-a-vi...attribute
There is a removeHandler function to remove filters etc.
I use the following code to remove a filter which is set for anonymous users but should not be set for authenticated users:
How can we add the filter criteria in Views ?
How can we add the filter criteria in Views ?