From e7b112a584917be2d00622bd07fa45078ec435d7 Mon Sep 17 00:00:00 2001
From: escuriola <escuriola@gmail.com>
Date: Mon, 16 May 2022 13:45:34 +0200
Subject: [PATCH] OEL-1367: Remove non-standard button fields. Set the input
 name in the configuration. Add a guard clause if input name is not set.

---
 modules/oe_whitelabel_search/src/Form/SearchForm.php | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/modules/oe_whitelabel_search/src/Form/SearchForm.php b/modules/oe_whitelabel_search/src/Form/SearchForm.php
index ee0310a5..26b0edbb 100644
--- a/modules/oe_whitelabel_search/src/Form/SearchForm.php
+++ b/modules/oe_whitelabel_search/src/Form/SearchForm.php
@@ -45,13 +45,12 @@ class SearchForm extends FormBase {
    * {@inheritdoc}
    */
   public function buildForm(array $form, FormStateInterface $form_state, array $config = NULL): array {
+    if (empty($config['input']['name'])) {
+      return [];
+    }
     $form_state->set('oe_whitelabel_search_config', $config);
-    $input_value = '';
 
     $form['#region'] = $config['form']['region'];
-    if (!empty($config['input']['name'])) {
-      $input_value = $this->getRequest()->get($config['input']['name']);
-    }
 
     $form['search_input'] = [
       '#type' => 'textfield',
@@ -61,15 +60,12 @@ class SearchForm extends FormBase {
       '#margin_class' => 'mb-0',
       '#form_id' => $this->getFormId(),
       '#region' => $config['form']['region'],
-      '#default_value' => $input_value,
+      '#default_value' => $config['input']['name'],
       '#required' => TRUE,
     ];
 
     $form['submit'] = [
       '#type' => 'submit',
-      '#input' => TRUE,
-      '#is_button' => TRUE,
-      '#executes_submit_callback' => TRUE,
       '#form_id' => $this->getFormId(),
       '#region' => $config['form']['region'],
     ];
-- 
GitLab