public function validateForm(array &$form, FormStateInterface $form_state)
 {
     $collection_name = Html::escape($form['searchblox_collection']['#value']);
     try {
         $resp = searchblox_check_collection($collection_name);
         // check weather
     } catch (\Exception $e) {
         $resp = $e->getMessage();
         $form_state->setErrorByName('error', $this->t($resp));
     }
     if ($resp !== true) {
         $form_state->setErrorByName('error', $this->t($resp));
     }
 }
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (isset($form)) {
         if (isset($form['#token'])) {
             $collection_name = Html::escape($form['searchblox_collection']['#value']);
             $resp = searchblox_check_collection($collection_name);
             // check weather collection name is valid
             if ($resp !== true) {
                 $form_state->setErrorByName($resp);
             }
             if ($resp) {
                 \Drupal::state()->set('searchblox_collection', $collection_name);
                 $response = new RedirectResponse(\Drupal::url('searchblox.step3'));
                 $response->send();
                 return;
             }
         }
     }
 }