I am building 2 custom Content entity types: one is a Node type representing a type of food, called "food". This food may have multiple varieties, which will differ with regards to specific details, so I wish to store information about the varieties in a separate database table, and to accomplish this I have defined a second entity type called "food_type" which serves to provide additional information related to the "food" node.

Within the Food form, I want to also fill out all the fields for the related food_type. I am trying to accomplish this using inline_entity_form.

Following the documentation, I have done the following things for food_type:

  • Added a dependency of inline_entity_form in food_type.info.yml (there are no other dependencies)
  • Created food_type/src/Controller/FoodTypeInlineEntityFormController.php, which contains the following code:

    namespace Drupal\food_type\Controller;
     * Controller routines for Food Type pages.
    class FoodTypeInlineEntityFormController extends EntityInlineEntityFormController {
       * Overrides EntityInlineEntityFormController::entityForm().
      public function entityForm($entity_form, &$form_state) {
        return parent::entityForm($entity_form, $form_state);
  • Added the following code to food_type_install() in food_type.install:

    $entity_info['food_type']['inline entity form'] = array(
        'controller' => 'FoodTypeInlineEntityFormController',
  • Defined '\Drupal\food_type\Controller\FoodTypeInlineEntityFormController::entityForm' as the _controller default under entity.food_type.form in food_type.routing.yml

I cannot enable the food_type module. Attempting to do so yields the following error:

Fatal error: Class 'Drupal\food_type\Controller\EntityInlineEntityFormController' not found in {directory}\sites\all\modules\custom\food_type\src\Controller\FoodTypeInlineEntityFormController.php on line 9

I assume this is caused because I do not include a use statement in FoodTypeInlineEntityFormController.php for EntityInlineEntityFormController. From Googling, it seems that such a statement is not used in example code that uses this module at all, and it's supposed to simply work when the inline_entity_form module is enabled. However, I for sure have inline_entity_form enabled and am still getting this error.

I would like to try a use statement, but the EntityInlineEntityFormController class does not seem to exist at all in the module code, as far as I can tell from searching. I am using 8.x-1.0-alpha6.

I am very new to drupal development and believe I am probably doing something else wrong, but I am completely at a loss here as to how to proceed or troubleshoot. Can anyone please help me or point me in the right direction?

Thank you in advance.

  • It looks to me like the README did not get updated between the 7.x branch and the 8.x branch, so those instructions are probably totally wrong. I don't think the issue is you. I would suggest opening an issue in the issue queue. Jul 11, 2016 at 18:23
  • I can try to write a full response later, traveling today. I recommend looking at the Drupal Commerce 2.x source. We implement IEF in two content entity base fields (product and orders) Jul 11, 2016 at 19:43
  • Thank you both. I will look at the source for Drupal Commerce 2.x and will also open an issue.
    – saramm1
    Jul 12, 2016 at 13:26
  • @MattGlaman, I am wondering if your offer to write a full response is still on the table - I have been working through the Drupal Commerce code but am having difficulty understanding just how everything works together. This is probably because I am new to Drupal development, but the use of IEF is something I am struggling a lot with. Thank you very much for your initial response, if you don't have time I understand, but figured I would ask :)
    – saramm1
    Jul 19, 2016 at 15:38

1 Answer 1


In order to implement Inline Entity form in D8, all you need to do is set your entity reference field to use the IEF widget - simple or complex. That is all. No additional work.

Here is how we set it up in Drupal Commerce for products, programmatically.

$form_display = commerce_get_entity_display('commerce_product', $product_type->id(), 'form');
$form_display->setComponent('variations', [
  'type' => 'inline_entity_form_complex',
  'weight' => 10,
  'settings' => [
    'override_labels' => TRUE,
    'label_singular' => 'variation',
    'label_plural' => 'variations',

This tells the variations field, which is a Product Variation entity reference, to use IEF as the way to manage field values.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.