function FieldConfigAddController::fieldConfigAddConfigureForm

Same name in other branches
  1. 11.x core/modules/field_ui/src/Controller/FieldConfigAddController.php \Drupal\field_ui\Controller\FieldConfigAddController::fieldConfigAddConfigureForm()

Builds the field config instance form.

Parameters

string $entity_type: The entity type.

string $field_name: The name of the field to create.

Return value

array The field instance edit form.

File

core/modules/field_ui/src/Controller/FieldConfigAddController.php, line 49

Class

FieldConfigAddController
Controller for building the field instance form.

Namespace

Drupal\field_ui\Controller

Code

public function fieldConfigAddConfigureForm(string $entity_type, string $field_name) : array {
    // @see \Drupal\field_ui\Form\FieldStorageAddForm::submitForm
    $temp_storage = $this->tempStore
        ->get($entity_type . ':' . $field_name);
    if (!$temp_storage) {
        throw new NotFoundHttpException();
    }
    
    /** @var \Drupal\Core\Field\FieldConfigInterface $entity */
    $entity = $this->entityTypeManager()
        ->getStorage('field_config')
        ->create([
        $temp_storage['field_config_values'],
        'field_storage' => $temp_storage['field_storage'],
    ]);
    return $this->entityFormBuilder()
        ->getForm($entity, 'default', [
        'default_options' => $temp_storage['default_options'],
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.