You are here

public function OnlyOneAdminSettings::buildForm in Allow a content type only once (Only One) 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 ConfigFormBase::buildForm

File

src/Form/OnlyOneAdminSettings.php, line 71

Class

OnlyOneAdminSettings
Class OnlyOneAdminSettings.

Namespace

Drupal\onlyone\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['onlyone_new_menu_entry'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show configured content types in a new menu entry'),
    '#description' => $this
      ->t("If you check this item a new menu entry named 'Add content (Only One)' will be created in Administration » Content, and all the configured content types to have Only One content will be moved there."),
    '#default_value' => $this
      ->config('onlyone.settings')
      ->get('onlyone_new_menu_entry'),
  ];
  $form['onlyone_redirect'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Redirect user to node edit form'),
    '#description' => $this
      ->t("If you check this item the user will be redirected to the one node's edit form. Otherwise users will be redirected to the existing one node's canonical URL."),
    '#default_value' => $this
      ->config('onlyone.settings')
      ->get('onlyone_redirect'),
  ];
  return parent::buildForm($form, $form_state);
}