You are here

public function FlexiformEntityFormDisplay::getFormInformation in Flexiform 8

Get the entity form builder.

This is designed to be helpful for enhancers that want to inspect the resultant form before providing configuration options.

Return value

array An array with two keys:

File

src/FlexiformEntityFormDisplay.php, line 571

Class

FlexiformEntityFormDisplay
Defines a class to extend EntityFormDisplays.

Namespace

Drupal\flexiform

Code

public function getFormInformation() {
  $operation = $this
    ->get('originalMode') ?: $this
    ->get('mode');
  $form_object = \Drupal::service('flexiform.manager')
    ->getFormObject($this);
  $default_values = [];
  if ($bundle_key = $this
    ->entityTypeManager()
    ->getDefinition($this
    ->getTargetEntityTypeId())
    ->getKey('bundle')) {
    $default_values[$bundle_key] = $this
      ->getTargetBundle();
  }
  $form_object
    ->setEntity($this
    ->entityTypeManager()
    ->getStorage($this
    ->getTargetEntityTypeId())
    ->create($default_values));
  $form_state = new FormState();
  return [
    'form_object' => $form_object,
    'form_state' => $form_state,
    'form' => \Drupal::service('form_builder')
      ->buildForm($form_object, $form_state),
  ];
}