You are here

public function FieldGroupAddForm::buildForm in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Form/FieldGroupAddForm.php \Drupal\field_group\Form\FieldGroupAddForm::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 FormInterface::buildForm

File

src/Form/FieldGroupAddForm.php, line 67

Class

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

Namespace

Drupal\field_group\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL, $context = NULL) {
  if ($context == 'form') {
    $this->mode = \Drupal::request()
      ->get('form_mode_name');
  }
  else {
    $this->mode = \Drupal::request()
      ->get('view_mode_name');
  }
  if (empty($this->mode)) {
    $this->mode = 'default';
  }
  if (!$form_state
    ->get('context')) {
    $form_state
      ->set('context', $context);
  }
  if (!$form_state
    ->get('entity_type_id')) {
    $form_state
      ->set('entity_type_id', $entity_type_id);
  }
  if (!$form_state
    ->get('bundle')) {
    $form_state
      ->set('bundle', $bundle);
  }
  if (!$form_state
    ->get('step')) {
    $form_state
      ->set('step', 'formatter');
  }
  $this->entityTypeId = $form_state
    ->get('entity_type_id');
  $this->bundle = $form_state
    ->get('bundle');
  $this->context = $form_state
    ->get('context');
  $this->currentStep = $form_state
    ->get('step');
  if ($this->currentStep == 'formatter') {
    $this
      ->buildFormatterSelectionForm($form, $form_state);
  }
  else {
    $this
      ->buildConfigurationForm($form, $form_state);
  }
  return $form;
}