Inline entity form (IEF) is a module that lets you create other nodes/entity inside of a node edit form (or reference them).

I would like to theme the form edit screen using a tpl.php file. (By form edit screen, I mean the place where the inline form is displayed for the user to input data and not the display that shows the finished form (e.g. so the 'edit' part and not the 'view' part),

This thread explains how to change values of the fields of the IEF creation screen. But it doesn't show how to use a tpl.php.file.

This tutorial and this tutorial explain how to theme forms. However, their knowledge doesn't seem to apply to Inline Entity forms (mainly because IEF forms don't use a form element).

1 Answer 1


I found the following answer here: http://site-machines.ru/blog/temizaciya-inline-entity-form-v-drupal


When using Inline entityform time to time it is necessary to make it more beautiful, more than matching the concept of the site. There are several ways to implement this, segodyan I will talk about one of the - the use of theming template.

As Inline entityform is the usual form, so it has a minima must be some hook_alter. See the documentation that is the way to be in the module - inline_entity_form.api.php. The documentation found the right hook - hook_inline_entity_form_entity_form_alter.

At the entrance is just fed our inline form.

The next step is adding theming function

/ ** * hook_inline_entity_form_entity_form_alter * / function sm_inline_entity_form_entity_form_alter (& $ entity_form, & $ form_state) { // Added theme function $ Entity_form [ '# theme'] [] = 'inline_entity_form_entity_form_'. $ Entity_form [ '# bundle']; dpm ($ entity_form); } I almost forgot to say the magic is done in our template.php form.

I told him what happened, what we've done in the previous paragraph? We've added a feature to our temizaitsii inline form, not just for one but for all. devel dpm () function module will help us to examine the insides of our Inline form

The next step in our magic, it template.php create hook_theme and declare it a template for our inline form

/ ** * Implements hook_theme (). * / function sm_theme ($ existing, $ type, $ theme, $ path) { $ Items [ 'inline_entity_form_entity_form_shoes'] = array ( 'Render element' => 'form', 'Template' => 'inline-entity-form-entity-form-shoes', // This will set to module / theme path by default: 'Path' => drupal_get_path ( 'theme', 'sm'). '/ Templates / inline_form', ); return $ items; } Just be sure to create our template file and we put him on the scullery indicated in the 'path' hook_theme.

Then I inserted the following code template

<-! Start inline-entity-form-entity-form-shoes.tpl.php ->

<-! @ See sm_theme adn template.php ->

Then we look at what we will give dpm (), continue using drupal_render output fields in the required manner

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.