SuggestionBlockForm.php in Autocomplete Search Suggestions 3.0.x
File
src/Form/SuggestionBlockForm.php
View source
<?php
namespace Drupal\suggestion\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\suggestion\SuggestionHelper;
class SuggestionBlockForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$cfg = SuggestionHelper::getConfig();
$form['#action'] = $cfg->action;
$form['#form_id'] = 'suggestion_block_form';
$form['#method'] = 'get';
$form['keys'] = [
'#type' => 'search',
'#title' => $this
->t('Search'),
'#title_display' => 'invisible',
'#size' => $cfg->max,
'#default_value' => '',
'#attributes' => [
'title' => $this
->t('Enter the terms you wish to search for.'),
],
'#autocomplete_route_name' => 'suggestion.autocomplete',
];
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#name' => '',
'#attributes' => [
'class' => [
'search-form__submit',
],
],
'#value' => $this
->t('Search'),
],
];
return $form;
}
public function getFormId() {
return 'suggestion_block_form';
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}