0

Use-case-scenario: There are multiple content types. There is the webform module. Context and Views are used.

Requirement: Display specific webform below specific node. The content editor should be able to choose specific form for specific node.

My first idea is: ->start with adding a node/entity reference field (lets call it "webform_node_url")in the webform, so that a webform is related with a specific node. ->create a view that renders all webforms that have "webform_node_url" ->Embedding this view in the context.

But the problem I have is, I cant find entity/reference functionality for the webform. Do you have any ideas and/or suggestions.

1 Answer 1

2

I think you should be able to do this fairly easily, without even involving views or contexts!

Here's how you can do it:

  1. Just like you said, you can create a new Entity Reference field that will point to the relevant webform. I'd make this field an Autocomplete (Tags style) field: enter image description here

  2. When you're setting up your field, make sure to select that it should only pull from your Webform content type: enter image description here

  3. When you've created the new field, make sure you hit the 'Manage Display' settings on the content type that includes this webform reference. Here's where the real magic is going to happen: you can have this new referenced entity (which is your webform) be displayed not as a link, but as a rendered entity. Which means you can just automatically display the webform under or above your node, or whereever you choose to output it. In my case, I made it the very last field (so it displays under my node), and here are the exact settings: enter image description here

Now test: If you go to create a new content type, you should be able to just start typing in the title of the webform you want to attach (such as "Contact Us"), and all the matching webforms will pop up - just choose the right one, save, and it should appear under your node.

enter image description here

Voila!

Let us know if it works for you.

3
  • Hi, thanks for the answer. It works. I did it few days ago, but didn't know about "rendered entity" trick. That could have saved me the whole trouble of: putting it in a View, embeding this view in a context. But I will know for next time. Blagodarya :) Commented Dec 11, 2013 at 4:18
  • Even though, just to say... I started the other way around. drupal.stackexchange.com/questions/33845/… Since there are around 13 content types in this particular website and all of them need this form reference :D . Commented Dec 11, 2013 at 9:03
  • Niama zashto. ;-) So glad it worked! Commented Dec 11, 2013 at 14:13

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.