2

I have the same problem like this View exposed filter block no alter form with ajax but for Drupal 8.

I have form alter where I change exposed filter label and some options in the select box, but when I choose some option that is submitted with auto submit and works with AJAX, form alter is not called and I get old label and options for the filter.

Any suggestions?

UPDATE: I think that is working now. This comment pointed me in wrong (maybe?) direction: https://api.drupal.org/comment/61807#comment-61807

I've been using mymodule.view_execution.inc file and functions for my views are executed on first page load but later mostly ignored.

Now I moved that code to mytheme.theme file and it seems ok for now.

  • could you share the code that you have tried so far? – O V Mar 14 '17 at 17:34
  • function mymodule_form_views_exposed_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){ if ($form['#id'] == 'views-exposed-form-press-releases-block-1') { $form['field_date_value']['#options']['All'] = t('All Years'); } } It's working now. But if you add it to mymodule.view_execution.inc then it's not working always. So I moved it in mytheme.theme and it's working fine now. – blastoise Mar 15 '17 at 12:31
  • This only works on the first page load, values return to default after every ajax call. – webmaniac Feb 6 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.