You are here

public function NgLightboxSettingsForm::buildForm in NG Lightbox 8

Same name and namespace in other branches
  1. 2.x src/Form/NgLightboxSettingsForm.php \Drupal\ng_lightbox\Form\NgLightboxSettingsForm::buildForm()

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/NgLightboxSettingsForm.php, line 50

Class

NgLightboxSettingsForm

Namespace

Drupal\ng_lightbox\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this->config = $this
    ->configFactory()
    ->getEditable('ng_lightbox.settings');
  $form['container']['patterns'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Paths'),
    '#default_value' => $this->config
      ->get('patterns'),
    '#description' => $this
      ->t('New line separated paths that must start with a leading slash. Wildcard character is *. E.g. /comment/*/reply.'),
  ];
  $form['container']['default_width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Default Width'),
    '#default_value' => $this->config
      ->get('default_width'),
    '#description' => $this
      ->t('The default width for modals opened with NG Lightbox.'),
  ];
  $form['container']['lightbox_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Lightbox Class'),
    '#default_value' => $this->config
      ->get('lightbox_class'),
    '#description' => $this
      ->t('The css custom class for modals opened with NG Lightbox.'),
  ];
  $form['container']['skip_admin_paths'] = [
    '#title' => $this
      ->t('Skip all admin paths'),
    '#type' => 'checkbox',
    '#default_value' => $this->config
      ->get('skip_admin_paths'),
    '#description' => $this
      ->t('This will exclude all admin paths from the lightbox. If you want some paths, see hook_ng_lightbox_ajax_path_alter().'),
  ];
  $form['container']['renderer'] = [
    '#title' => $this
      ->t('Renderer'),
    '#type' => 'select',
    '#default_value' => $this->config
      ->get('renderer') ?: NgLightbox::DEFAULT_MODAL,
    '#description' => $this
      ->t('Select which renderer should be used for the lightbox.'),
    '#options' => $this->renderers,
  ];
  return parent::buildForm($form, $form_state);
}