You are here

public function FormModeManagerForm::buildForm in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 src/Form/FormModeManagerForm.php \Drupal\form_mode_manager\Form\FormModeManagerForm::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/FormModeManagerForm.php, line 95

Class

FormModeManagerForm
Configure Form Mode Manager common settings.

Namespace

Drupal\form_mode_manager\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form_modes = $this->formModeManager
    ->getAllFormModesDefinitions(TRUE);
  $form['vertical_tabs'] = [
    '#type' => 'vertical_tabs',
  ];
  foreach ($form_modes as $entity_type_id => $modes) {
    $options = array_combine(array_keys($modes), array_keys($modes));
    $form[$entity_type_id] = [
      '#type' => 'details',
      '#title' => $entity_type_id,
      '#group' => 'vertical_tabs',
    ];
    $form[$entity_type_id]['element_' . $entity_type_id] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Choose what form_mode you need to exclude of Form Mode Manager process.'),
      '#options' => $options,
      '#multiple' => TRUE,
      '#default_value' => $this->settings
        ->get("form_modes.{$entity_type_id}.to_exclude"),
    ];
  }
  return parent::buildForm($form, $form_state);
}