I added a Language custom field ( a taxonomy term ) to my user entity and another entity (Activity).
This field can have 2 values, English and French. (User can have both, activity can only have one)
On the Activities view, i added an exposed filter (select) so the user can filter French or English activities.
Result :
I want to hide (or disable) this select if the user only has 1 Language.
How to properly achieve this ? i tried the pre_render hooks but i can't find the right one i guess.
Thank you.
you should try this hook:
function themename_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['views_exposed_form'])) {
if ($form['#id'] == "views-exposed-form-custom-search-page-1") { // your form id
// your filter logic and return filter form value like
// $form["langugae"]["#options"] = $options;
}
}
}