123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace Drupal\materio_sapi\Form;
- use Drupal\Core\Form\FormBase;
- use Drupal\Core\Form\FormStateInterface;
- /**
- * Class MaterioSapiSearchForm.
- */
- class MaterioSapiSearchForm extends FormBase {
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'materio_sapi_search_form';
- }
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state) {
- $form['search'] = [
- '#type' => 'textfield',
- // '#title' => $this->t('Search'),
- '#maxlength' => 64,
- '#size' => 25,
- '#weight' => '0',
- '#attributes' => [
- "placeholder" => $this->t('Search'),
- // "@keyup" => "keyup",
- "@keyup.enter" => "submit",
- "v-model" => "typed",
- "v-focus" => "",
- // "v-on:select" => "typed",
- ],
- '#autocomplete_route_name' => 'materio_sapi.search_autocomplete',
- ];
- $form['searchautocomplete'] = [
- '#type' => 'hidden',
- '#attributes' => [
- "v-model" => "autocomplete"
- ],
- ];
- // $form['submit'] = [
- // '#type' => 'submit',
- // '#value' => $this->t('Search'),
- // '#attributes' => [
- // '@click.prevent' => "submit",
- // ]
- // ];
- $form['submit'] = array(
- '#type' => 'button',
- // '#src' => '',//drupal_get_path('module', 'materio_search_api') . '/images/search.png',
- '#value' => t('Search'),
- // '#prefix' => '<div class="search-btn-wrapper">',
- // '#suffix'=> '</div>',
- '#attributes' => [
- 'title' => t('Search'),
- '@click.prevent' => "submit",
- ]
- );
- return $form;
- }
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, FormStateInterface $form_state) {
- parent::validateForm($form, $form_state);
- }
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- // Display result.
- foreach ($form_state->getValues() as $key => $value) {
- drupal_set_message($key . ': ' . $value);
- }
- }
- }
|