Last updated February 19, 2015. Created on July 26, 2013.
Edited by nielsdefeyter, firfin, timodwhit. Log in to edit this page.

To load an Entityform into a block, there are three ways of accomplishing this:

There is a module for that

Allows to load a specified entity form as a block.
After enabling the module, the entityforms will have an optional checkbox to make them a block.
Entityform block

Leveraging Entity API and Views

It is possible to quite easily do this using views. I got this from https://drupal.org/node/1599352#comment-7040050 , thanks @drupov

  • Create a new view
  • On the "Add new view" page choose "Show: Entityform Type"
  • Check "Create a block" and under "Display format" choose "Fields" (not "Rendered Entity")
  • In your view settings be sure to add the field "Entityform Type: Rendered Entityform Type"
  • The important settings for the field are "Display: Show Complete Entity" and in the appearing dropdown select "Full content"
  • You should also add a filter "Entityform Type: Internal, numeric entityform type ID" and give it the value/ID of the form or what I find more elegant is the filter "Entityform Type: Machine-readable name" and give it the machine name of the entity form.

This isn't tested om multi-page forms.
BEWARE: In the entityform module settings you can setup which roles should be able to submit the forms. When you create a block in this way these settings are being overriden by views and even if you dissallow the anonymous user to submit the form in the module settings, having the view being visible by "View published content" would make the form appear.
So you have to apply the same access settings to your view.

Hardcoded into module/template

If you have a template/module that will output to a template you will can use a code similar to this:

<?php
 
  module_load_include
('inc', 'entityform', 'entityform.admin');
 
$entity_form_name = '';
 
$render_estimate_form = entityform_form_wrapper(entityform_empty_load($entity_form_name), 'submit', 'embedded');
  echo
drupal_render($render_estimate_form);
 
?>

This code will need to be adjusted for each use case. Make sure to declare the $entity_form_name variable.

Automagically

Or if you would like to have multiple entity forms as blocks, you can use the sandbox module: Entityforms Blocks
Edit 02-2015: probably succeeded by Entityform Block

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Matters’s picture

Hi, I encountered the same problem: when render entityform in views_php, then lost pager

kopeboy’s picture

Doesn't work with new entity form, 7.x-2.0-rc1

During views configuration I get HTTP 500 error, and on the page where I put the block I will have a BLANK PAGE.

kingandy’s picture

The code worked for me as provided, on 7.x-2.0-rc1 (after I set "$entity_form_name" to my entityform type machine name). Maybe it's an incompatibility with views?

++Andy
Developing Drupal websites for Livelink New Media since 2008