12/1/2021

Inline_entity_form

Inline Entity Form is a useful module for reference entities and being able to edit them in place.

Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent - children one (product display - products, order - line items, etc.), where the child entities are never managed outside the parent form. Existing entities can also be referenced. Supports commerceproductreference, commercelineitemreference. Jan 21, 2015 Overview Adds a Entity Reference field type with revision support. It's based on the core Entity Reference module but allows you to reference a specific entity revision. This is useful for modules like Paragraphs and Inline Entity Form. A common usecase is where an entity is actually part of a parent entity (with an embedded entity form). When the parent entity is updated, the referenced. CiviCRM Entity Reference Field is a submodule of the CiviCRM Entity project. One of the many advantages of installing the CiviCRM Entity module is the ability to use Drupal’s Entity Reference module to reference CiviCRM data from nodes, terms, or other entity types. Many people are using the Inline Entity Form module, which provides field widgets that allow you to create, edit, or delete a. Navigate to the Entityform administration page located at STRUCTURE-ENTITYFORM TYPES (admin/structure/entityformtypes) and click the “Add Entityform Type” link. Fill in the basic form information, including Entityform name and any instructions you want to be displayed above the form. The Inline Entity Form module provides a widget for reference fields that allows inline management (add / edit / delete) of referenced entities. It provides an excellent solution to the product display - product UI problems, allowing the products (called 'variations' in the UI) to.

Here’s what the edit form looks like out of the box for an unlimited value entity reference:

Inline_entity_form Reference Form

Often it’s helpful to provide additional information to your editors.

If you have a look at inline_entity_form.module you will find a function called theme_inline_entity_form_entity_table(). Within this you will see how this table is built, and how you can manipulate the form to add additional columns of information.

Here’s an example (mymodule.module) showing how I am able to add two additional fields to the table:

  • sow = top level content type
  • field_sow_er_lis = entity reference field in sow content type that references sowli nodes
  • sowli = content type being referenced
  • field_sowli_timeline = term reference field in sowli content type
  • field_sowli_source = term reference field in sowli content type
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
* Implements hook_form_FORM_ID_alter().
functionmymodule_form_node_sow_edit_form_alter(&$form,&$form_state,$form_id){
// See inline_entity_form.module theme_inline_entity_form_entity_table().
$cols=&$form['field_sow_er_lis']['widget']['entities']['#table_fields'];
'type'=>'field',
'weight'=>105,
$cols['field_sowli_source']=[
'label'=>t('Source'),
];
$keys=Element::children($form['field_sow_er_lis']['widget']['entities']);
foreach($keysas$key){
$entity=&$form['field_sow_er_lis']['widget']['entities'][$key];
if($timeline_tid=$entity['#entity']->field_sowli_timeline->target_id){
'#markup'=>Term::load($timeline_tid)->getName(),
}
if($source_tid=$entity['#entity']->field_sowli_source->target_id){
'#markup'=>Term::load($source_tid)->getName(),
}
}
Here’s the result:

CiviCRM Entity Reference Field is a submodule of the CiviCRM Entity project. One of the many advantages of installing the CiviCRM Entity module is the ability to use Drupal’s Entity Reference module to reference CiviCRM data from nodes, terms, or other entity types. Many people are using the Inline Entity Form module, which provides field widgets that allow you to create, edit, or delete a referenced entity from the parent form.

If you reference CiviCRM contacts via an Entity Reference field and use Inline Entity Form, you’ll often want to include the ability for the user to create or edit subsidiary CiviCRM entity types, such as the email, phone, and address entities. This can get tricky with CiviCRM integration. A regular entity reference field stores a target entity id in a Drupal field table of the Drupal database. CiviCRM Addresses are stored in the CiviCRM database, and can be created by different types of users and in many different ways. In addition, Drupal and CiviCRM reference data in opposite ways. Drupal’s field model, “forward references,” which means the entity stores the ids of the child entities. CiviCRM generally uses “backreferences,” meaning the child entity will store the parent entity’s id. To make the situation even more interesting, this pattern is not consistently followed in CiviCRM, and you’ll occasionally have a “forward reference”. For example, events store a location block id, and the location block references addresses.

We want the convenient and familiar interface of the Inline Entity Form/Entityreference combination, but we want to use the existing data from the CiviCRM tables, and not store target ids in Drupal field tables, while at the same time being flexible enough to go both ways. We want to make a square peg to fit into a round hole. What we needed was a “remote reference field”.

The Drupal Field API is very powerful, and it allows you to make field types that are disconnected from the standard Drupal field tables. The solution is CiviCRM Entity Reference Field, which adds a new field type that can be added to any CiviCRM entity type.

We’ve successfully used this module for a variety of use cases, including:

Inline Entity Form

Inline_entity_form drupal 8

Drupal Inline Entity Form

  • Referencing emails, addresses, phones from contacts
  • Referencing participants from events
  • Referencing relationships from contacts
  • Referencing activities from contacts
  • Referencing contacts from activities
  • Referencing contacts from relationships

Inline Entity Form Alter Drupal 8

It is also possible to have CiviCRM Entity Reference (CER) fields on entities referenced by CER fields. For example, In CiviCRM, Events reference location blocks, which in turn reference addresses. To edit profiles on Events, you need to reference UFJoin from Events. The UFJoin entity type needs a UFGroup reference field which needs to reference UFField. That case is especially interesting as that “line of reference” runs both forward and backwards from the UFGroup entity.

Inline_entity_form.api.php

That’s the what and the why, to see an example of how to use it, please continue reading this article on Skvare.com.