You are here

public function FormModeManagerForm::buildFormPerEntity in Form mode manager 8.2

Build form element per compatible entities.

Parameters

array $form: An associative array containing the structure of the form.

array $form_modes: The form modes collection for given entity type.

string $entity_type_id: The entity type ID of entity.

Return value

string The name of the theme

Overrides FormModeManagerFormBase::buildFormPerEntity

File

src/Form/FormModeManagerForm.php, line 62

Class

FormModeManagerForm
Configure Form Mode Manager common settings.

Namespace

Drupal\form_mode_manager\Form

Code

public function buildFormPerEntity(array &$form, array $form_modes, $entity_type_id) {
  $options = array_combine(array_keys($form_modes[$entity_type_id]), array_keys($form_modes[$entity_type_id]));
  $entity_label = $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->getEntityType()
    ->getLabel();
  $form[$entity_type_id] = [
    '#type' => 'details',
    '#title' => $entity_label,
    '#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"),
    '#empty_value' => '_none',
    '#empty_option' => $this
      ->t('- Any -'),
  ];
  return $this;
}