public function TransactionInlineForm::entityForm in Transaction 8
Builds the entity form.
Parameters
array $entity_form: The entity form, containing the following basic properties:
- #entity: The entity for the current entity form.
- #op: The form operation. 'add' or 'edit'.
- #form_mode: The form mode used to display the entity form.
- #parents: Identifies the position of the entity form in the overall parent form, and identifies the location where the field values are placed within $form_state->getValues().
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the parent form.
Overrides EntityInlineForm::entityForm
File
- modules/
transaction_ief/ src/ Form/ TransactionInlineForm.php, line 73
Class
- TransactionInlineForm
- Defines the inline form for the transaction entity.
Namespace
Drupal\transaction_ief\FormCode
public function entityForm(array $entity_form, FormStateInterface $form_state) {
/** @var \Drupal\transaction\TransactionInterface $transaction */
$transaction = $entity_form['#entity'];
// Discover the target entity by examining the current route or by getting
// from the request argument with the same name as the target entity type.
if (!$transaction
->getTargetEntityId()) {
$route_options = $this->routeMatch
->getRouteObject()
->getOptions();
$target_entity_type_id = isset($route_options['_transaction_target_entity_type_id']) ? $route_options['_transaction_target_entity_type_id'] : $transaction
->getType()
->getTargetEntityTypeId();
if ($target_entity = $this->requestStack
->getCurrentRequest()
->get($target_entity_type_id)) {
$transaction
->setTargetEntity($target_entity);
}
}
return parent::entityForm($entity_form, $form_state);
}