You are here

public function LibraryGeneralSettings::buildForm in Library 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/LibraryGeneralSettings.php, line 23

Class

LibraryGeneralSettings
General settings form.

Namespace

Drupal\library\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) : array {
  $config = $this
    ->config('library.settings');
  $form['header'] = [
    '#markup' => '<h2>' . $this
      ->t('Getting started') . '</h2>',
  ];
  $form['notice'] = [
    '#markup' => '<p>' . $this
      ->t('To make use of this module add at least one <em>library item entry</em> to a content type.') . '</p>',
  ];
  $form['barcode_starting_point'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Barcode starting point'),
    '#description' => $this
      ->t('The value to begin the auto-incrementation for barcodes from. Only effective if you do not have a value set in items, yet.'),
    '#default_value' => $config
      ->get('barcode_starting_point'),
  ];
  $form['anonymize_transactions'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Anonymize transactions'),
    '#description' => $this
      ->t('Whether to remove patron information for returned items periodically.'),
    '#options' => [
      'never' => $this
        ->t('never'),
      'daily' => $this
        ->t('daily'),
      'weekly' => $this
        ->t('weekly'),
      'monthly' => $this
        ->t('monthly'),
    ],
    '#default_value' => $config
      ->get('anonymize_transactions'),
    '#size' => 1,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}