|
@@ -22,6 +22,8 @@ class MaterioSapiSearchForm extends FormBase {
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
|
|
+ $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
|
|
+
|
|
|
$form['search'] = [
|
|
|
'#type' => 'textfield',
|
|
|
// '#title' => $this->t('Search'),
|
|
@@ -66,10 +68,16 @@ class MaterioSapiSearchForm extends FormBase {
|
|
|
$terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);
|
|
|
|
|
|
foreach ($terms as $tid => $term) {
|
|
|
- $childs = $term->get('field_terms')->getValue();
|
|
|
+ if($term->hasTranslation($lang)){
|
|
|
+ $term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $lang);
|
|
|
+ }
|
|
|
$options = array($term->getName());
|
|
|
+ $childs = $term->get('field_terms')->getValue();
|
|
|
foreach ($childs as $child) {
|
|
|
$child_term = \Drupal\taxonomy\Entity\Term::load($child['target_id']);
|
|
|
+ if($child_term->hasTranslation($lang)){
|
|
|
+ $child_term = \Drupal::service('entity.repository')->getTranslationFromContext($child_term, $lang);
|
|
|
+ }
|
|
|
$options[$child_term->id()] = $child_term->getName();
|
|
|
}
|
|
|
$form['filters']['filter-'.$tid] = array(
|