You are here

public function AdminForm::buildForm in UIkit Components 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/AdminForm.php \Drupal\uikit_components\Form\AdminForm::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/AdminForm.php, line 21

Class

AdminForm

Namespace

Drupal\uikit_components\Form

Code

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

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

  // Default settings.
  $config = $this
    ->config('uikit_components.settings');

  // Get UIkit framework version from UIkit base theme.
  $uikit_version = UIkitComponents::getUIkitLibraryVersion();

  // UIkit framework version field.
  if ($uikit_version) {
    $form['uikit_framework_version'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('UIkit Framework Version'),
      '#markup' => $uikit_version ? $uikit_version : $this
        ->t('The UIkit base theme is not installed.'),
    ];
    $form['additional_menu_styles'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable configurable menu styles'),
      '#description' => $this
        ->t('Enable selecting menu styles when adding and editing <a href="/admin/structure/menu">menus</a>. This provides three new menu templates: <em class="placeholder">menu--default.html.twig</em> as a default, <em class="placeholder">menu--uk-menu.html.twig</em> for uk-list and uk-subnav menus and <em class="placeholder">menu--uk-nav.html.twig</em> for uk-nav menus. This also ignores the admin toolbar and devel module menus so they can be rendered correctly.'),
      '#default_value' => $config
        ->get('additional_menu_styles'),
    ];
  }
  return $form;
}