You are here

public function WishlistSearchForm::buildForm in UC Wish List 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/WishlistSearchForm.php, line 48

Class

WishlistSearchForm

Namespace

Drupal\uc_wishlist\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = [];
  $form['search'] = [
    '#type' => 'fieldset',
  ];
  $form['search']['keywords'] = [
    '#type' => 'textfield',
    '#title' => t('Search keywords'),
    '#description' => t('Enter the keywords to use to search wish list titles and addresses.'),
    '#default_value' => $keywords,
  ];
  $form['search']['submit'] = [
    '#type' => 'submit',
    '#value' => t('Search'),
  ];
  $links = [];
  if (!empty($links)) {
    $output = [
      'links' => $links,
      'attributes' => [
        'class' => [
          'wishlist',
        ],
      ],
      'heading' => NULL,
    ];
  }
  else {
    $output = ' ' . t('No wish lists found.');
  }
  $form['output'] = [
    '#type' => 'item',
    '#markup' => Xss::filter('<div><h2>' . t('Wish lists:') . '</h2>' . $output . '</div>'),
  ];
  return $form;
}