public function SearchForm::buildForm in Simple Google Custom Search Engine 8
Same name and namespace in other branches
- 2.0.x src/Form/SearchForm.php \Drupal\simple_gse_search\Form\SearchForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ SearchForm.php, line 24
Class
- SearchForm
- Defines a form for performing a simple redirect to display search results.
Namespace
Drupal\simple_gse_search\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['s'] = [
'#type' => 'textfield',
'#title' => t('Search'),
'#default_value' => $form_state
->getValue('s', $this
->getRequest()->query
->get('s', '')),
'#attributes' => [
'placeholder' => $this
->t('Search site...'),
'class' => [
'SearchForm-input',
],
],
'#theme_wrappers' => [],
'#size' => NULL,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('go'),
'#attributes' => [
'class' => [
'SearchForm-submit',
],
],
];
$form['#attributes'] = [
'class' => [
'SearchForm',
],
];
return $form;
}