3 namespace Drupal\Core\Render\Element;
5 use Drupal\Core\Render\Element;
8 * Provides an HTML5 input element with type of "search".
12 * $form['search'] = array(
13 * '#type' => 'search',
14 * '#title' => $this->t('Search'),
18 * @see \Drupal\Core\Render\Element\Textfield
20 * @FormElement("search")
22 class Search extends FormElement {
27 public function getInfo() {
28 $class = get_class($this);
33 '#autocomplete_route_name' => FALSE,
35 [$class, 'processAutocomplete'],
36 [$class, 'processAjaxForm'],
39 [$class, 'preRenderSearch'],
41 '#theme' => 'input__search',
42 '#theme_wrappers' => ['form_element'],
47 * Prepares a #type 'search' render element for input.html.twig.
49 * @param array $element
50 * An associative array containing the properties of the element.
51 * Properties used: #title, #value, #description, #size, #maxlength,
52 * #placeholder, #required, #attributes.
55 * The $element with prepared variables ready for input.html.twig.
57 public static function preRenderSearch($element) {
58 $element['#attributes']['type'] = 'search';
59 Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']);
60 static::setAttributes($element, ['form-search']);