- Issue created by @danflanagan8
- πΊπΈUnited States danflanagan8 St. Louis, US
I'm going to put in a real MR with some test coverage, but the hook is going to look something like this:
/** * Remove types from exposed filters when 'Is Micro-content' filter is in use. * * Implements hook_form_views_exposed_form_alter(). */ function micronode_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($view = $form_state->getStorage()['view']) { $filters = $view->getHandlers('filter'); if (isset($filters['micronode_is_microcontent'])) { $return_microcontent = $view->display_handler->getHandler('filter', 'micronode_is_microcontent')->value; $allowed_bundles = array_keys(micronode_get_node_types($return_microcontent)); foreach ($filters as $id => $definition) { if (isset($definition['exposed']) && $definition['exposed'] && $definition['plugin_id'] == 'bundle') { foreach ($form[$id]['#options'] as $key => $value) { if (is_string($value) && !in_array($key, $allowed_bundles, TRUE)) { unset($form[$id]['#options'][$key]); } } } } } } }
This is a refactored version of something originally conceived of and written by the @allie micka. We need to make sure to give credit if and when it comes to that! I love this feature, though, and hopefully it's not too hard to sell. :)
- Status changed to Needs review
6 months ago 7:50pm 6 September 2024 - πΊπΈUnited States danflanagan8 St. Louis, US
I put in an MR with the hook and some test coverage. It looks like tests aren't set up to run on Gitlab for this project, but the MicronodeViewsTest passes locally for me.
- First commit to issue fork.
- πΊπΈUnited States Allie Micka
marcoscano β credited allie micka β .
-
marcoscano β
committed f838c739 on 1.0.x authored by
danflanagan8 β
Issue #3472635 by danflanagan8, marcoscano, allie micka: Automatically...
-
marcoscano β
committed f838c739 on 1.0.x authored by
danflanagan8 β
- Status changed to Fixed
6 months ago 5:12pm 8 September 2024 - πͺπΈSpain marcoscano Barcelona, Spain
Looks good to me, thanks for contributing! π
Automatically closed - issue fixed for 2 weeks with no activity.