Download & Extend

Embed an Entityform in a Block

Project:Entityforms
Version:7.x-1.x-dev
Component:Documentation
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I'm wondering if there is any way to embed an entityform in a block or perhaps in the footer of a View? Is there a snippet of php I could use to render the form? If not, is there any plan to implement this sort of functionality?

Thanks!

Comments

#1

I should also point out that I did try using Entity Reference to display it in the footer of a View, but I couldn't get it to render the form. It would only display the title.

Edit: After some searching, I found the Bean module for building your own blocks as entities. I was able to add an entity reference field and use it to display my form when viewing a preview of my block, but as soon as I placed that block in my sidebar, it no longer rendered the form. The block would show up but it was empty. Any ideas?

#2

IMO, Bean is definitely the say forward when it comes to blocks in Drupal 7, and a lot of modulers are starting to provide integration. Perhaps an entityform_bean module to bridge the gap would be a nice addition, which would may even just need mimic what you did with your custom bean and entityreference field to some extent.

#3

Yes I have been using a combination Bean and Entity Reference for the embedding Entityforms in blocks in testing.

@Arrow to get it to display you have to set it to "rendered entity" in the manage display and then click the setting icon to set it to "Rendered as Full content". I was able to use it is this manner.

@mrfelton, I think entityform_bean is good idea but don't plan to make it a submodule, at least not for 1.x. It would be good as another contrib module. Though even if it wasn't module it is pretty easy to set up. Could just be exported Feature. It wouldn't need any coding.

#4

Yeah, so following in the vain of other bean plugins, probably bean_entityform as opposed to entityform_bean, and as ou say - probably just a basic feature module.

#5

I've written a module that can create a block out of any entity form type (similar to webform block). If anyone is interested, I'll post it as a project.

#6

@drush fan I think that would interesting to look at. At least post it as a sandbox project. Thanks. Ted

#7

Ok, I've opened a sandbox project with the code I've got for now.

#8

Sorry to be lazy (unknowing) about getting git going, but can you upload the zip file?

#9

Status:active» closed (won't fix)

I am going to close this issue. @hellomobe if you need help with the sandbox project you can create an issue in that project.

Thanks

#10

@hellomobe I have also created a sandbox project that uses the Bean/Entity Reference method

http://drupal.org/sandbox/tedbow/1774070

To get the tar file of a sandbox project(without dealing git)

  1. Click the "Repository Viewer" link on the project page
  2. Click the first "snapshot" link on the page.

#11

Using bean with entity reference or this sandox project works great, but there still undesired effect, the entity_form_wrapper callback override every page title where block with an entityform is shown, solution is simply to comment drupal_set_title() function on entityform.admin.inc line 206
But this title is used on admin page, so i'm not sure it's the best solution.

Regards.
Jean

#12

@mogtofu33, thanks for reporting issue could you make new issue for the drupal_set_title problem.

Basically this is going to effect any entityform that you have embedded via block, panel, or entity reference. So I will make it a priority to solve.

Thanks,
Tedbow

#13

@mogtofu33 I create an issue and a patch. #1820020: Embedded entityforms(panels,entityreference, etc) overrides page title

Please review if you get chance

#14

I also did experience this problem while embedding entityform as a mini panel. Applying this patch solved the problem for me too.

#15

Status:closed (won't fix)» needs review

I've created a simple patch that creates block for each entityform type.
I think it is important to provide such kind of functionality out-of-the-box instead of using additional module (I mean Entityform Block). It becomes a useful feature to ease migration from Webform.
Please review.

#16

Sorry, here is the patch.

AttachmentSizeStatusTest resultOperations
entityform-added_default_block_for_every_entityform-1599352-15.patch1.1 KBIdlePASSED: [[SimpleTest]]: [MySQL] 296 pass(es).View details | Re-test

#17

Tweak that deals with the problem described in #1820020: Embedded entityforms(panels,entityreference, etc) overrides page title: avoids page title overriding.

AttachmentSizeStatusTest resultOperations
entityform-added_default_block_for_every_entityform-1599352-17.patch1.12 KBIdlePASSED: [[SimpleTest]]: [MySQL] 296 pass(es).View details | Re-test

#18

Status:needs review» needs work

@Staratel thanks for the patch. But I think I would prefer this to be a separate module. Or at lease a sub module.

In any case I think there should at least be a checkbox on the entityform type edit form to ask "expose as block?". If a site has tons of entityforms this would fill up the block admin page as it is now.

Also does the method work with multi-page forms created using Field Group. I don't think it would or at least might have some unexpected results.

I am marking as a possible feature for 2.x(as a submodule) to get feedback

#19

Well, there is a way to make it work with views:

  • 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.

Entities are awesome, right? :)

I haven't tested this with multipage forms as of #18, but for simple forms it works just great.

Anyway, thanks for the great module! Having a module that takes advantage of the build in Field API in Drupal and the magic that entity aware modules supply to such approach is great.

#20

One more thing to keep in mind though!

In the entityform module settings you can setup which roles should be able to submit the forms.

When you create a block as in #19 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.

#21

Thanks to mrupal in #19, that worked just fine!

#22

Removing entityform-2.x feature tag because I don't see this as part of 2.x.

I think could easily be put into another module.