Suppose I am building a twitter-like site, and allow members to form groups with OG. So I have set up a view to list all the posts in a given group. However, I would like to embed a content creation form in the header (similar to how twitter is at the moment) with group audience set automatically to the group (therefore is not shown as an option in the form). Is there a way to do it without writing code (I haven't been doing drupal module development after D6...)?

  • I am using commons. As you know, everything on commons in associated with groups. How I can assign everything to single group automatically and hide it on the site.
    – Umair
    Jun 12, 2017 at 10:52
  • commons? what is it?
    – Jeffrey04
    Jun 14, 2017 at 7:48
  • It is a distribution
    – Umair
    Jun 14, 2017 at 7:58

2 Answers 2


It doesn't have to be in the view header. Just place it block above the view and adjust the css so they sit together.

If you use entity forms and entity form blocks, you can just place a block above the view block (or panel pane).

Rules will allow you to create a new node, set the current OG_context as the new new node's group and then redirect back to the same page or to the new node.

  • so practically i can create an entity form, and somehow do something to publish a new content node (via rules?)? what if I do not have the OG_context set, cos the page I want to embed the form is actually a views page (OG_context can be set in a views?)?
    – Jeffrey04
    Mar 28, 2016 at 5:25
  • It would make more sense for the view to be a block or panel in a group node. That way the new nodes will be subgroups. Then you can have different parent pages. As for rules, yea, you add an event for saving an entity form, add "entity has field" conditions and then actions to create new entity and set data or list fields. Mar 28, 2016 at 6:56
  • Erm, now I have created an entity form with just the body field (from the content node), but i still don't see how everything is linked together @.@ so I include the form block to the group node page? how do I get the form to include the group nid?
    – Jeffrey04
    Apr 17, 2016 at 9:48
  • In your rule, there should be a site:Current node from OG context or something like that. Use that to set the group for the node you create. I think you need the OG context module enabled. Apr 18, 2016 at 4:16
  • If that doesn't work, I think you can create an entity reference field on the entity form and use the entity form prepopulate module and set it to hidden. That way the entity form has the OG node automatically for you to use in rules. Apr 18, 2016 at 4:18

So based on @Niall Murphy's answer, my solution to the problem is as follows:

  1. Instead of embeding the form in a view, I create an entity form and make it available as a block with entity forms block module. Then the block is shown in all the group content type node.
  2. Also, in order to prepopulate the group id in the block, I installed Organic Groups Entityform Integration for that purpose.
  3. Then I use the rules module to capture the form submission event, and then check if it has the fields in the entity form. If the fields exist, then I create a new content. Then the value value of the content is copied from the submitted form. Lastly, the form itself is deleted as they are not needed anymore.
  • bug: doesn't consider organic group permission
    – Jeffrey04
    Apr 17, 2016 at 17:07
  • just found out about entity rules, figuring out how to get the form access rules working
    – Jeffrey04
    Apr 18, 2016 at 3:01

Your Answer

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

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