You are here

public function FlexiformFormEntityBase::configurationForm in Flexiform 8

Prepare a configuration form.

Overrides FlexiformFormEntityInterface::configurationForm

3 calls to FlexiformFormEntityBase::configurationForm()
FlexiformFormEntityProvided::configurationForm in src/Plugin/FlexiformFormEntity/FlexiformFormEntityProvided.php
Prepare a configuration form.
FlexiformFormEntityTypedDataReferencedEntity::configurationForm in src/Plugin/FlexiformFormEntity/FlexiformFormEntityTypedDataReferencedEntity.php
Prepare a configuration form.
UserProfile::configurationForm in src/Plugin/FlexiformFormEntity/UserProfile.php
Prepare a configuration form.
3 methods override FlexiformFormEntityBase::configurationForm()
FlexiformFormEntityProvided::configurationForm in src/Plugin/FlexiformFormEntity/FlexiformFormEntityProvided.php
Prepare a configuration form.
FlexiformFormEntityTypedDataReferencedEntity::configurationForm in src/Plugin/FlexiformFormEntity/FlexiformFormEntityTypedDataReferencedEntity.php
Prepare a configuration form.
UserProfile::configurationForm in src/Plugin/FlexiformFormEntity/UserProfile.php
Prepare a configuration form.

File

src/FormEntity/FlexiformFormEntityBase.php, line 150

Class

FlexiformFormEntityBase
Provides the base form entity plugin.

Namespace

Drupal\flexiform\FormEntity

Code

public function configurationForm(array $form, FormStateInterface $form_state) {
  $form['save_on_submit'] = [
    '#type' => 'checkbox',
    '#title' => t('Save this Entity when the form is submitted.'),
    '#default_value' => isset($this->configuration['save_on_submit']) ? $this->configuration['save_on_submit'] : TRUE,
  ];
  $form['context_mapping'] = [
    '#type' => 'container',
    '#tree' => TRUE,
  ];
  if (empty($this->pluginDefinition['context']) || !is_array($this->pluginDefinition['context'])) {
    return $form;
  }
  foreach ($this->pluginDefinition['context'] as $key => $context_definition) {
    $matching_contexts = $this
      ->contextHandler()
      ->getMatchingContexts($this->formEntityManager
      ->getContexts(), $context_definition);
    $context_options = [];
    foreach ($matching_contexts as $context) {
      $context_options[$context
        ->getEntityNamespace()] = $context
        ->getContextDefinition()
        ->getLabel();
    }
    $form['context_mapping'][$key] = [
      '#type' => 'select',
      '#title' => $context_definition
        ->getLabel(),
      '#options' => $context_options,
      '#default_value' => !empty($this->configuration['context_mapping'][$key]) ? $this->configuration['context_mapping'][$key] : NULL,
    ];
  }
  return $form;
}