You are here

protected function InlineEntityFormBase::getInlineEntityForm in Inline Entity Form 8

Gets inline entity form element.

Parameters

string $operation: The operation (i.e. 'add' or 'edit').

string $bundle: Entity bundle.

string $langcode: Entity langcode.

array $parents: Array of parent element names.

\Drupal\Core\Entity\EntityInterface $entity: Optional entity object.

Return value

array IEF form element structure.

2 calls to InlineEntityFormBase::getInlineEntityForm()
InlineEntityFormComplex::formElement in src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
Returns the form for a single field widget.
InlineEntityFormSimple::formElement in src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/InlineEntityFormBase.php, line 420

Class

InlineEntityFormBase
Inline entity form widget base class.

Namespace

Drupal\inline_entity_form\Plugin\Field\FieldWidget

Code

protected function getInlineEntityForm($operation, $bundle, $langcode, $delta, array $parents, EntityInterface $entity = NULL) {
  $element = [
    '#type' => 'inline_entity_form',
    '#entity_type' => $this
      ->getFieldSetting('target_type'),
    '#bundle' => $bundle,
    '#langcode' => $langcode,
    '#default_value' => $entity,
    '#op' => $operation,
    '#form_mode' => $this
      ->getSetting('form_mode'),
    '#revision' => $this
      ->getSetting('revision'),
    '#save_entity' => FALSE,
    '#ief_row_delta' => $delta,
    // Used by Field API and controller methods to find the relevant
    // values in $form_state.
    '#parents' => $parents,
    // Labels could be overridden in field widget settings. We won't have
    // access to those in static callbacks (#process, ...) so let's add
    // them here.
    '#ief_labels' => $this
      ->getEntityTypeLabels(),
    // Identifies the IEF widget to which the form belongs.
    '#ief_id' => $this
      ->getIefId(),
  ];
  return $element;
}