function transaction_inline_entity_form_entity_form_alter in Transaction 8
Implements hook_inline_entity_form_entity_form_alter().
Provides basic integration with the inline_entity_form module. For full integration, enable the transaction_ief submodule.
File
- ./
transaction.module, line 35
Code
function transaction_inline_entity_form_entity_form_alter(array $entity_form, FormStateInterface $form_state) {
// Transaction IEF submodule makes this better.
if (\Drupal::moduleHandler()
->moduleExists('transaction_ief')) {
return $entity_form;
}
// Set the target entity type in the transaction if not set.
$entity = $entity_form['#entity'];
if ($entity instanceof TransactionInterface && !$entity
->getTargetEntityId()) {
$entity
->setTargetEntity(\Drupal::request()
->get($entity
->getType()
->getTargetEntityTypeId()));
}
return $entity_form;
}