You are here

public function ConfigForm::buildForm in Rest menu items 8.2

Same name and namespace in other branches
  1. 3.0.x src/Form/ConfigForm.php \Drupal\rest_menu_items\Form\ConfigForm::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/ConfigForm.php, line 32

Class

ConfigForm
Class ConfigForm.

Namespace

Drupal\rest_menu_items\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('rest_menu_items.config');
  $form['output_values'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('What values do you need in the output?'),
    '#options' => [
      'key' => $this
        ->t('Key'),
      'title' => $this
        ->t('Title'),
      'description' => $this
        ->t('Description'),
      'uri' => $this
        ->t('Uri'),
      'alias' => $this
        ->t('Alias'),
      'external' => $this
        ->t('External'),
      'absolute' => $this
        ->t('Absolute'),
      'relative' => $this
        ->t('Relative'),
      'existing' => $this
        ->t('Existing'),
      'weight' => $this
        ->t('Weight'),
      'expanded' => $this
        ->t('Expanded'),
      'enabled' => $this
        ->t('Enabled'),
      'uuid' => $this
        ->t('Uuid'),
      'options' => $this
        ->t('Options'),
    ],
    '#default_value' => empty($config
      ->get('output_values')) ? [] : $config
      ->get('output_values'),
  ];
  $form['base_url'] = [
    '#type' => 'textfield',
    '#default_value' => $config
      ->get('base_url'),
    '#title' => $this
      ->t('Base URL'),
    '#description' => $this
      ->t('This url is used as the base url in the absolute links.'),
  ];
  $form['add_fragment'] = [
    '#type' => 'checkbox',
    '#default_value' => $config
      ->get('add_fragment'),
    '#title' => $this
      ->t('Add the fragment (#id) to the url'),
    '#description' => $this
      ->t('This adds the #id (fragment, anchor link) to the outputted url.'),
  ];
  return parent::buildForm($form, $form_state);
}