'fieldgroup', '#title' => $this->t('Search'), 'keys' => [ '#type' => 'search', // '#autocomplete_route_name' => 'edlp_search.edlp_search_controller_autocomplete', // '#autocomplete_route_parameters' => array('field_name' => 'title'), '#maxlength' => 20, '#size' => 15, '#weight' => '0', ] ]; $form['fieldset_langues'] = [ '#type' => 'fieldgroup', '#title' => $this->t('Language'), 'language' => [ '#type' => 'textfield', '#autocomplete_route_name' => 'edlp_search.edlp_search_controller_autocomplete', '#autocomplete_route_parameters' => array('field_name' => 'field_langues'), '#maxlength' => 20, '#size' => 15, '#weight' => '0', ] ]; $form['fieldset_genre'] = [ '#type'=>'fieldgroup', '#title' => $this->t('Genres'), 'genres' => [ '#type' => 'textfield', '#autocomplete_route_name' => 'edlp_search.edlp_search_controller_autocomplete', '#autocomplete_route_parameters' => array('field_name' => 'field_genres', 'field_synonyms' => 'field_synonyms'), '#maxlength' => 20, '#size' => 15, '#weight' => '0', ] ]; $this->getEntries(); $form['entries'] = [ '#type' => 'checkboxes', '#title' => $this->t('Entries'), '#options' => $this->entries, '#weight' => '1', ]; $form['search'] = [ '#type' => 'submit', '#title' => $this->t('Search'), '#value' => $this->t('Search'), '#weight' => '99', ]; return $form; } private function getEntries(){ $query = \Drupal::entityQuery('taxonomy_term') ->condition('vid', 'entrees'); $tids = $query->execute(); $terms = entity_load_multiple('taxonomy_term', $tids); // dsm($terms); foreach ($terms as $term) { // dpm($term->toArray()); $tid = $term->id(); $name = $term->getName(); // remove masqué $sid = WorkflowManager::getCurrentStateId($term, 'field_workflow'); if($sid == 'generique_masque') continue; $entries[$tid] = $name; } asort($entries); $this->entries = $entries; } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // if (strlen($form_state->getValue('keys')) < 3) { // $form_state->setErrorByName('keys', $this->t('Search string is to short. Please enter more than 3 characters.')); // } } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Display result. foreach ($form_state->getValues() as $key => $value) { drupal_set_message($key . ': ' . $value); } } }