I have a "Request more info" Entity Forms Type form that is accessed from basically every content type in the website, with a Menu Tab link created via Views. I attempted at adding both a NodeReference and Entity Reference with Prepopulate without successs. The closest I get is having a Select List displaying all Nodes from all referenced Content Types (Hundreds). Is it possible to have this field pre-populated instead of the user having to choose from a long list of Node Titles?
1 Answer
Prepopulate works by lifting values from the request url and inserting them into the rendered form. If it is not in $_GET it will not appear. Using views with a menu tab will mean that you will have to add parameters to the url whether you use Prepopulate or not. I think you should back up and reconsider your approach.
I would suggest exposing the form as a block right on the pages you want. That way the page is easier to identify. If you use Bean it is a simple matter to create a block for your Entity Form Type.
- Enable the Bean and Bean UI modules.
- Go to /admin/structure/block-types and click 'Add new block type'.
- Give the block type a name (eg Entity Form Type Block).
- Under 'Manage fields' add an 'Entity reference' field. Select box widget is fine.
- Under 'Manage display' select 'Rendered entity' and 'Render as full content'.
- Go to /admin/content/blocks and click 'Add new block'.
- Give the block a Label (eg. Request more information block) and a title.
- Select your form from the dropdown, and save.
- Go to /admin/structure/views/add and create a view called 'Node List' showing 'content' of type 'all'. Uncheck the 'Page' display. You are creating the master only. Click 'Save and Continue'.
- In the view edit screen, Add a display -> references.
- Configure the 'Title' field and uncheck everything (no label, no link).
Under 'Advanced' configure a contextual filter in Content:NID. Check 'Provide default value' and select 'Content ID from URL'. Save your view.
Go to /admin/structure/entityform_types and click 'Manage fields' for your entity form. Edit the nodereference field and set it to required, number of values = 1, and at te bottom under 'Views - Nodes that can be referenced' select your 'Node list - references' view.
Go to /admin/structure/block and set your block to display on the nodes you want, and for the roles you want. It is important to note that the block permissions will override any access permissions you have set on the form.
The entity form will now display on the selected pages, and the user will be required to select the node reference to submit the form. The list presented will be limited to the current page.
-
Thank you SO much Triskelion. I understood right before coming back to see if there was any responses to this, that I needed to change my approach. I had created an Entity Views specifically for the Autocomplete, with the NIDs, but it wasn't autocompleting anyway, and I was beginning to understand it had to do with the URL given to the Menu Tab....I just wasn't sure how to solve it. I can't thank you enough for your input.– caraMar 20, 2013 at 22:32
-
A downside: after installing Bean, all existing blocks regions were set to none, and I'm unable to save them to their previous positions...– caraMar 21, 2013 at 9:09
-
Ok, I thought it was worth mentioning. My installation had a real bad conflict with UUID (It wasn't the BEan Module but UUID Module what was giving me all sort of errors, including missing and broken entity handlers for Views related to Profile2. So I started uninstalling modules, first Bean, then UUID, and checking performance, and the best part is now I DO GET only ONE CHoice in my EntityForm (the one accessed from the Menu Tab, and it's the choice of the parent NODE! The only problem is it comes with the html tags .... like <span class=" views-field-title-yaddayadda">Node Title </span>– caraMar 21, 2013 at 10:05
-
Ok. Unchecking "Add views classes" and checking "Strip all HTML" tags, fixed the above. So basically I achieved what I wanted with a mixture of my approach and yours. Thank you!– caraMar 21, 2013 at 11:26
-
Perhaps I should have said Only activate Bean and Bean UI. Glad you have iy working, Mar 21, 2013 at 12:23