You are here

public function CustomBreadcrumbsSettingsForm::buildForm in Custom Breadcrumbs 1.x

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/CustomBreadcrumbsSettingsForm.php, line 30

Class

CustomBreadcrumbsSettingsForm
Configure Custom breadcrumb settings for this site.

Namespace

Drupal\custom_breadcrumbs\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('custom_breadcrumbs.settings');
  $form['home'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Prepend default "Home" link'),
    '#default_value' => $config
      ->get('home'),
  ];
  $form['home_link'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('"Home" text'),
    '#default_value' => $config
      ->get('home_link'),
    '#states' => [
      'visible' => [
        'input[name="home"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['current_page'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Append curent page title like the latest crumb'),
    '#default_value' => $config
      ->get('current_page'),
  ];
  $form['current_page_link'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Last crumb with link'),
    '#default_value' => $config
      ->get('current_page_link'),
    '#states' => [
      'visible' => [
        'input[name="current_page"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['trim_title'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Trim title length'),
    '#default_value' => $config
      ->get('trim_title'),
    '#min' => 0,
  ];
  $form['admin_pages_disable'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable on admin pages'),
    '#description' => $this
      ->t('If checked, Custom breadcrumb will be disabled on admin pages.'),
    '#default_value' => $config
      ->get('admin_pages_disable'),
  ];
  return parent::buildForm($form, $form_state);
}