Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

DamienMcKenna’s picture

It seems like the goal was to move this functionality into CTools, instead of core: #1790006: Add a autosubmit exposed form plugin

DamienMcKenna’s picture

FYI the problem with the plan of "move it into CTools" is that CTools has been scrapped and needs to be rewritten.

We could see about rerolling the patch from #1790006 and turning it into a tiny module.

larowlan’s picture

Category: Bug report » Feature request
DamienMcKenna’s picture

Status: Active » Needs review
FileSize
3.72 KB

Here's a small module I put together based on the patch. I'm happy to spin it off as a tiny submodule, but I think it'd be better being included in either core or CTools.

forestmars’s picture

+1 for including views_filter_autosubmit in CTools.

lauriii’s picture

Version: 8.0.x-dev » 8.1.x-dev
glynster’s picture

++++++++++++++++++1 as a tiny sub module, better still add to views, does not matter, this is such a small and very valuable feature on many of our projects. @DamienMcKenna Thanks for the module works a treat!

AswathyAjish’s picture

This module worked for me. Thanks a lot.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Project: Drupal core » Ctools
Version: 8.2.x-dev »
Component: views.module » Code

Let's move it to ctools, as there is nothing in core we could do about it.

DamienMcKenna’s picture

Project: Ctools » Chaos Tool Suite (ctools)
Version: » 8.x-3.x-dev

Moving it to the correct project ;-)

I still don't see why this wouldn't fit in core?

dom18fr’s picture

FileSize
8.82 KB

Thanks DamienMacKenna for your module, it did the job for me.
However it seems that a call to
parent::exposedFormAlter($form, $form_state);
is missing, and it cause sort input render fail.
I just added this line in the attached zip.

sonfd’s picture

Awesome! I was wondering what happened to this option.

It's a little awkward with autocomplete filters and especially awkward if you select an item with Tab. Not really sure of the best way to fix this issue (nor do I remember what happens in d7), just wanted to put it on radar.

sonfd’s picture

Just uninstalled (drush pmu views_filter_autosubmit) this and the view that I had enabled auto-submission on was deleted. I noticed no uninstall hook here so it must be something in core?

Arvey’s picture

The custom module created. Is it still working? It is not working on my views preview. I'm using Drupal 8.1.0.

pheraph’s picture

@Arvey: I see the Autosubmit as a filter option, but it doesn't work for me, too (Filters are placed in a block).

DamienMcKenna’s picture

Status: Needs review » Needs work

Seems like it needs work, then.

mark.labrecque’s picture

Thanks Damien! This worked great for me on core v8.1.7 and solved an immediate need for me. If I find any issues with it, I will try to contribute back any fixes I come up with. Until the Ctools debate gets solved, maybe we could get this up as a sandbox project, so others can find it?

Thanks again!

ilya.no’s picture

Status: Needs work » Needs review
FileSize
5.84 KB

DamienMacKenna, thanks for the module! Works for me too. I've created patch from it, to be used also.

andypost’s picture

There's some issues with JS (needs work a bit for previews and keybindings)

  1. +++ b/modules/ctools_views/src/Plugin/views/exposed_form/Autosubmit.php
    @@ -0,0 +1,67 @@
    +  protected function defineOptions() {
    ...
    +    $options['autosubmit_hide'] = array('default' => TRUE);
    

    do that needs schema updates?

  2. +++ b/modules/ctools_views/src/Plugin/views/exposed_form/Autosubmit.php
    @@ -0,0 +1,67 @@
    +    parent::exposedFormAlter($form, $form_state);
    +    ¶
    

    minor, trailing whitespace

id.tarzanych’s picture

FileSize
5.85 KB
2.05 KB

Fixed JavaScript code for input fields.
Please review my patch.

andypost’s picture

+++ b/modules/ctools_views/js/auto-submit.js
@@ -0,0 +1,95 @@
+    $('.views-auto-submit-full-form input:text, input:text.views-auto-submit', context)
+        .once('views-auto-submit').each(function () {
+      // each textinput element has his own timeout
+      var timeoutID = 0;
+      $(this)
+          .bind('keydown keyup', function (e) {
+            if ($.inArray(e.keyCode, discardKeyCode) === -1) {

I still find this indent is wrong

NetNerdy’s picture

Issue tags: +views autosubmit

patch #24 without results => test failed
localhost Drupal 8.1.8, php 7

DuneBL’s picture

I have patched ctools with #24 then refresh the cache... those are the only things I have done
But I couldn't see the "hide submit button" under "Exposed form style" of an old view that I plan to convert into an autosubmit view...
Maybe I missed something?
I use Drupal 8.2

ilya.no’s picture

@NerdyCrowd, could you, please, describe your problem more precisely? Like did you use clean install or some additional modules? And what does "patch #24 without results => test failed"? It fails for views without results? Or it means your own test is failed? If so, please, describe your case.
@DuneBL, do you have ctools_views module enabled? If so, maybe you can try reinstalling it after patching?

DuneBL’s picture

@ilya.no many thanks for your answer: you was right, ctools_views was not installed. Thus I install it and I could choose "Autosubmit" for ""Exposed form style".
Unfortunately, my submit button is still there (even after clearing caches)
I have 3 select and 1 autocomplete texte field (from the "Views Autocomplete Filters" module)
I don't know if this is important, bu I have also tried to change the "Apply" text of the submit button, but nothing changed.

DuneBL’s picture

@ilya.no: This is working... I have made a wrong manipulation, the patch is doing the job!!!
Sorry for loosing your time

andypost’s picture

@DuneBL which patch are you using? #22 or #24

andypost’s picture

Status: Needs review » Reviewed & tested by the community

#24 looks ready to go

DuneBL’s picture

@andypost: #24

tandroid’s picture

For anyone following this thread, if you apply #24 before installing "ctools_views" it will not work. You will need to uninstall and reinstall the module as @ilya.no mentioned in #28, but doing this will delete the entire view if you changed any settings that are provided by "ctools_views" so BE CAREFUL! Luckily, I had already exported my view to config.

tandroid’s picture

#24 is not working for me when the filters are exposed as a block. Just looking into it briefly, it seems like it's not getting the views-auto-submit-full-form html class.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I suspect this needs a reroll and some tests to confirm it still works as intended.

flyke’s picture

Confirming that enabling ctools_views and applying patch #24 works very well like it should here.

zincdesign’s picture

- I installed ctools_views
- applied the patch 24
- uninstalled ctools_views and reinstalled ctools_views

Cleared cache

I checked my view and the autosubmit option is still not available to me. What am I doing wrong?

Drupal 8.2.2
Views 8.2.2
ctools_views 8.x-3.0-alpha27

heshanlk’s picture

The patch appeared to be working fine, @zincdesign you need to change the Exposed form style to Autosubmit to make it work.

pebosi’s picture

Patch works for me too.

ahmadhalah’s picture

Awesome ... Its working fine

c_c’s picture

Thanks for the work on this patch. I applied patch #24 to ctools 8.x-3.0-alpha27, but I am seeing that autosubmit only works with dropdown menus and does not provide you with an option to configure it to use other types of exposed filters. All of the exposed filters on the site i'm working on are checkboxes and im trying to get the checkboxes to autosubmit using patch #24. Ive tried this creating a new view page with an autosubmit exposed filter, and also editing an existing view that currently uses checkboxes and the Apply button to filter. How do you get the autosubmit functionality to work with checkboxes? Is there something i need to specify on the backend in custom code to do this?

Ralf Eisler’s picture

Thanks for the patch. It works on ctools_views 8.x-3.0-alpha27 and 8.x-3.0-beta1.

Arlina’s picture

Confirming this works for ctools_views 8.x-3.0-alpha27.
Thanks!

Manuel Garcia’s picture

Drive by nitpick:

+++ b/modules/ctools_views/js/auto-submit.js
@@ -0,0 +1,95 @@
+ *  '#attributes' => array('class' => array('views-auto-submit')),
...
+ *   '#attributes' => array('class' => array('views-auto-submit-full-form')),
...
+ *  '#attributes' => array('class' => array('views-use-ajax', 'views-auto-submit-click')),

+++ b/modules/ctools_views/src/Plugin/views/exposed_form/Autosubmit.php
@@ -0,0 +1,67 @@
+    $options['autosubmit_hide'] = array('default' => TRUE);
...
+    $form['autosubmit_hide'] = array(
+      '#type' => 'checkbox',
+      '#title' => $this->t('Hide submit button'),
+      '#description' => $this->t('Hide submit button if javascript is enabled.'),
+      '#default_value' => $this->options['autosubmit_hide'],
+    );
...
+    $form = array_merge_recursive($form, array('#attributes' => array('class' => array('views-auto-submit-full-form'))));

Can we switch to short array syntax?

kala4ek’s picture

Assigned: Unassigned » kala4ek
kala4ek’s picture

Assigned: kala4ek » Unassigned
Status: Needs work » Needs review
FileSize
5.79 KB

Switched to short array syntax.

Manuel Garcia’s picture

Status: Needs review » Needs work

Thanks @kala4ek, setting this to needs work for the tests =)

anruether’s picture

Thanks for your work!

#47 doesn't work if the exposed filter is in a block. Using ctools 8.x-3.0 and drupal 8.3.2.

acbramley’s picture

Can confirm #49, in fact enabling ctools_views makes my exposed sorts disappear completely even using the Basic type.

acbramley’s picture

#49/#50 is an unrelated bug, opened #2878418: Ctools views Block display plugin hides exposed sorts if views block has no exposed filters to track that.

EDIT: Can confirm with the above patch, #47 works well.

mikeker’s picture

FYI: CTools (7.x) autosubmit was added to Better Exposed Filters in #2764981: Add 'auto-submit' functionality to the exposed form about nine months ago.

Hope that helps folks still looking for this functionality, though I agree that this should be part of core.

Anybody’s picture

https://www.drupal.org/project/better_exposed_filters also offers the functionality for Drupal 8!

jbitdrop’s picture

Based on the last comments I wonder: can we set this issue Status to "fixed" then?

C13L0’s picture

Status: Needs work » Reviewed & tested by the community

Patch #47 works perfect, so changing status to Reviewed & tested by the community.

I don't think it has anything to do with this patch but I want to mention that ajax needs to be off when using the reset button or it will return you to the management view

jbitdrop’s picture

deleted (dunno why double post happend here. Maybe my browser.)

jbitdrop’s picture

@C13LO: I was referring to

https://www.drupal.org/project/better_exposed_filters also offers the functionality for Drupal 8!

mistakenly (wrong issue) but you are right, for Ctools it's RTBC.

oriol_e9g’s picture

I can confirm that #47 works and apllies cleanly

- Installing drupal/ctools (3.0.0): Loading from cache
- Applying patches for drupal/ctools
  https://www.drupal.org/files/issues/2475595-ctools-autocomplete-fix-47.patch (Views exposed filters missing autosubmit option)
mpotter’s picture

Status: Reviewed & tested by the community » Needs work

Not sure why this is marked as RTBC. As mentioned several times above, this does not work when using a Block for the exposed form. Not related to sort order. When I select "Expose Form in Block" and then select the "AutoSubmit" exposed form style, then ensure the "Hide Submit button" setting is enabled, then when I go to my page that has a Views Block and the Exposed Filter block, selecting a value from the filter dropdown (Content Type) doesn't auto-submit the Ajax form.

So either this needs more work to determine why this fails when using a Block, or this plugin needs to give a warning or error when it tries to be used when Expose in Block is enabled.

Will look at better_exposed_filters as an alternative, but don't think this issue is ready for committing.

Oksana Skotar’s picture

I've installed and activated the module from #13.
Could not find where is the option to activate the Autosubmit. Finally found.
See Your view > Advanced > Exposed form style > click on Basic > change to Autosubmit > check "Hide submit button" in settings of Exposed form style.
Works perfectly!

Grienauer’s picture

Used module from #13.
Worked but the Settings menu is not working.
The Settings menu won't open if I click it…

Dimiter’s picture

Using #47 works, but to improve UX and accessibility I'd propose to move the focus back to the input element after the Ajax submit is done.

Paulset’s picture

Any news ?

it is recommended to use the mode from # 13 or patch from # 47 ?

(I need an autosubmit for a filter exposed to my users (of type autocomplete))

bartmcpherson’s picture

Patch in #47 seems to still be good after 8.x-3.1.

Mr_DeLeTeD’s picture

I have try the #47 but i found this error while trying to updb
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "autosubmit" plugin does not exist.

C13L0’s picture

Status: Needs work » Reviewed & tested by the community
Mr_DeLeTeD commented 8 days ago
I have try the #47 but i found this error while trying to updb
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "autosubmit" plugin does not exist.

If you updated Updated Chaos tools (ctools) from 8.x-3.0 to 8.x-3.2 you will need to re-apply patch #42 to 8.x-3.2.

The patch still works flawlessly with 8.x-3.2

Updating status to reviewed and tested by the community.

Chi’s picture

It seems like the goal was to move this functionality into CTools, instead of core

That's not clear. What is wrong with having this in core? Seems like a pretty basic Views functionality.

joegl’s picture

Confirmed patch in #47 resolved our issue #3034834: Exception : "The autosubmit plugin does not exist."

init90’s picture

Also encountered with such problem after update module from Chaos Tool Suite (ctools) 8.x-3.0+1-dev (2017-May-19) to Chaos Tool Suite (ctools) 8.x-3.2 . The patch from #47 fixed problem for me.

C13L0’s picture

Please add this to the next commit. I have to re-apply this patch every time there is an update. Reviewed and tested for 8.x-3.4 and patch works great.

Manuel Garcia’s picture

Status: Reviewed & tested by the community » Needs work

See #59.

C13L0’s picture

The patch works perfectly fine with view blocks and ajax enabled. Message me and I will give you website to review.

Manuel Garcia’s picture

Are you using a block for the exposed form @C13L0 ¿?

C13L0’s picture

FileSize
346.02 KB

@Manuel Garcia,

This patch is being used for auto submit on a traditional Views block. The exposed filter is not in a separate block. I hope this clarifies. =)

Views block with exposed filter

Manuel Garcia’s picture

Thanks @C13L0 - I marked this this issue as needs work because on #59 it's noted that

this does not work when using a Block for the exposed form
jbitdrop’s picture

"Needs work" should be set by a user really testing and failing, not from a comment of another user ...

eworwa’s picture

Hi, I can confirm that patch on #47 applies and works just fine, my setup:
- Drupal 8.8.4
- CTOOLS 8.x-3.2

Also worth mentioning that the block it's been implemented through Layout Builder. I understand #59 might be an issue but it's 2 years old so maybe is no longer valid.

C13L0’s picture

8 months later and we are still using patch #47. I would love to see it committed. =)

rcodina’s picture

The patch doesn't work for me on a view using block display. I'm using Drupal 9.2.4 and Chaos Tool Suite 8.x-3.7. To get the autosubmit feature I have had to install Views Autosubmit module.

sorlov’s picture

Patch from #47 is missing config schema for new autosubmit exposed form plugin

sorlov’s picture

Status: Needs work » Needs review
FileSize
6.22 KB
428 bytes

Add config schema for autosubmit exposed form plugin from patch #47

hunchang’s picture

confirm patch #81 work on Drupal 9.2.16 & cTools 3.7 with contextual filter & exposed filter setup.

DuneBL’s picture

confirm also the #81 apply on ctools 4.0

Vanguardian’s picture

When upgrading to Drupal 10 the patch in #81 runs into problems with the deprecation of the jQuery once() method. Modified the patch to work with D10. Please feel free to make changes as needed but this worked for my instance. Currently using the 4.x branch and this applied well.

Rob230’s picture

I've seen this break on a number of D10 sites. Path in #84 fixes it.

DimaS11’s picture

I have already old 81 patch installed, so to use updated 84 needs to bump up the library version. I added an updated patch.