You are here

function FieldGroupAddForm::buildConfigurationForm in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Form/FieldGroupAddForm.php \Drupal\field_group\Form\FieldGroupAddForm::buildConfigurationForm()

Build the formatter configuration form.

1 call to FieldGroupAddForm::buildConfigurationForm()
FieldGroupAddForm::buildForm in src/Form/FieldGroupAddForm.php
Form constructor.

File

src/Form/FieldGroupAddForm.php, line 176

Class

FieldGroupAddForm
Provides a form for adding a fieldgroup to a bundle.

Namespace

Drupal\field_group\Form

Code

function buildConfigurationForm(array &$form, FormStateInterface $form_state) {
  $group = new \stdClass();
  $group->context = $this->context;
  $group->entity_type = $this->entityTypeId;
  $group->bundle = $this->bundle;
  $group->mode = $this->mode;
  $manager = \Drupal::service('plugin.manager.field_group.formatters');
  $plugin = $manager
    ->getInstance(array(
    'format_type' => $form_state
      ->getValue('group_formatter'),
    'configuration' => [
      'label' => $form_state
        ->getValue('label'),
    ],
    'group' => $group,
  ));
  $form['format_settings'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
  );
  $form['format_settings'] += $plugin
    ->settingsForm();
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Create group'),
    '#button_type' => 'primary',
  );
}