You are here

public function SimpleSearchFormLazyBuilder::getForm in Simple search form 8

Lazy builder callback to build the form.

Parameters

string $config: Simple search form configuration JSON.

Return value

array A render-able form array.

File

src/SimpleSearchFormLazyBuilder.php, line 48

Class

SimpleSearchFormLazyBuilder
Service for build a simple search form.

Namespace

Drupal\simple_search_form

Code

public function getForm($config) {
  $config = Json::decode($config);
  $form = $this->formBuilder
    ->getForm(SimpleSearchForm::class, $config);

  // Vary caching of this block per selected $_GET parameter when decided
  // to use "Keep value in search input after form submit" feature.
  if ($config['input_keep_value']) {
    $form['#cache']['contexts'][] = 'url.query_args:' . $config['get_parameter'];
  }
  return $form;
}