Skip to content
Snippets Groups Projects
Unverified Commit ccb97dd9 authored by briancanini's avatar briancanini Committed by GitHub
Browse files

Merge pull request #139 from ASCWebServices/view_term_label

Set taxonomy term filter labels to the taxonomy name
parents 02d47e20 81da6588
No related branches found
No related tags found
No related merge requests found
<?php
use \Drupal\taxonomy\Entity\Term;
use \Drupal\taxonomy\Entity\Vocabulary;
/**
* @file
* Bootstrap sub-theme.
......@@ -126,9 +129,34 @@ function asc_bootstrap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $
if(count($form['field_appointment_target_id']['#options']) == 0) {
$form['field_appointment_target_id']['#access'] = FALSE;
}
else {
$tid = array_shift(array_keys($form['field_appointment_target_id']['#options']));
$term = Term::load($tid);
if (!empty($term)) {
$vid = array_shift($term->vid->getValue())['target_id'];
if(!empty($vid)) {
$vocab = Vocabulary::load($vid);
$vocab_label = $vocab->get('name');
$form['#info']['filter-field_appointment_target_id']['label'] = $vocab_label;
}
}
}
if(count($form['field_research_interests_target_id']['#options']) == 0) {
$form['field_research_interests_target_id']['#access'] = FALSE;
}
else {
$tid = array_shift(array_keys($form['field_research_interests_target_id']['#options']));
$term = Term::load($tid);
if (!empty($term)) {
$vid = array_shift($term->vid->getValue())['target_id'];
if(!empty($vid)) {
$vocab = Vocabulary::load($vid);
$vocab_label = $vocab->get('name');
$form['#info']['filter-field_research_interests_target_id']['label'] = $vocab_label;
}
}
}
}
/*
......@@ -154,4 +182,4 @@ function asc_bootstrap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $
$form['field_appointment_target_id']['#weight'] = 3;
$form['field_research_interests_target_id']['#weight'] = 4;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment