You are here

public function SearchExcludeNidForm::buildForm in Search exclude nid 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 ConfigFormBase::buildForm

File

src/Form/SearchExcludeNidForm.php, line 23

Class

SearchExcludeNidForm
The form to collect nids to be excluded.

Namespace

Drupal\search_exclude_nid\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Form constructor.
  $form = parent::buildForm($form, $form_state);

  // Default settings.
  $config = $this
    ->config('search_exclude_nid.settings');
  $excluded_nids = $config
    ->get('excluded_nids');

  // Source text field.
  $form['excluded_nids'] = array(
    '#type' => 'textarea',
    '#title' => $this
      ->t('Nodes to be excluded'),
    '#default_value' => !empty($excluded_nids) ? implode(',', $excluded_nids) : '',
    '#description' => $this
      ->t('Comma separated list of node ids (node:nid) to be excluded, eg: 1,4,8,23 etc.'),
  );
  return $form;
}