Setting up Entity Reference content types, fields, views with Entity Reference Prepopulate add links

First, modules:

  • Views + CTools
  • Entity Views Attachments
  • Entity Reference 7.x-1.0-rc1
  • Entity reference prepopulate 7.x-1.0
  • References dialog 7.x-1.0-alpha3

Then, content types and fields:

  • Create four or more content types. For this example, I will use Client, Work, Task, and Note. Tasks and Notes can be 'attached to', e.g. entity reference, Client and Work nodes. Also, Work nodes can be attached to Clients. In my use case, I have several other content types, which can 'have' Tasks and Notes as well. The other content types in my use case also have entity references to Client and Work nodes.
  • Client is the ultimate parent content type, so you don't need any entity reference fields on it (unless you want them for some other purpose, of course).
  • On the Work content type, create an Entity Reference field using the autocomplete widget, called 'Client'. You can make it required if you want, but it does not have to be.
    • Check the "Enable Entity reference prepopulate" box, select "Disable field" for Action and "Do nothing" for Fallback behaviour. I usually set Skip access permission to "Administer site configuration".
    • If you want to enable the References Dialog widget to be able to add/edit a Client from the node add page for a Work, check the Edit and Add dialog boxes

  • In the 'Client' field settings, leave the Number of values at 1, Target type is "Node", and select "Client" for the Target bundles

  • Now, on the node add page for the Work content type, you will see the Client Entity Reference Field, with the Add Client link supplied by the References Dialog module:

  • Then, on your Task and Note content types, create (separate) Entity Reference fields called 'Attached to' (machine names: field_task_attachedto and field_note_attachedto), that can reference an unlimited number of Client, Work, and whatever other content types that you desire. You should use different fields for ease of management, but the settings are the same.
    • Check the "Enable Entity reference prepopulate" box, select "Disable field" for Action and "Do nothing" for Fallback behaviour. Set Skip access permission to "Administer site configuration".
    • You will not be able to use the References Dialog links since you are enabling the field to reference an unlimited number of different content types. With child content like "notes" and "tasks", you presumably are not going to be creating a parent, like a "client", when you are creating a "note" for the "client" - the "client" parent node will already exist.

  • In the Attached to field settings, select "Unlimited" for the Number of values, set the Target type to "Node", and select the Client, Work and any other content types to which you want to be able to attached Notes and Tasks under Target bundles.

  • Remember to create your "Attached to" Entity Reference field on both your Note and Task content types. If you recycle the field, it will have the same settings for both Notes and Tasks, so if you want to be able to attach Notes, but not Tasks, to some content types, then use two separate fields with the same settings.
  • First, create your Views to display the Notes and Tasks attached to a referencable node being viewed. I also have pages to display all of the Notes and Tasks, but I want to be able to see all of the Notes and Tasks attached to a Client or Work on the Client and Work nodes. Here, Entity Views Attachments (which is a great and useful module) comes into play. I'll use the example of Tasks again, but the process is basically the same for Notes - just change anything that was specific to Tasks to Notes when creating that View.
    • At admin/structure/views, click the "Add new view" link, name it something like "Attached Tasks" and select Show Content of type Task. Uncheck create a page, and leave create a block unchecked.
    • Use the "+Add" button near the top, to add an "Entity content" display to your newly created View
    • Under the "Entity Content Settings" pane, select "Node" for the "Entity type", and select the content types that can be referenced by the "Attached to" Entity Reference field on the Task content type (e.g., Client, Work, etc.). Leave Arguments at id. I opted to display the title of the View display by selecting "Yes" for Show title.
    • Add the fields that you want to display. Title is fine for now.
  • Then create your contextual filter, so that this Entity Views Attachment display only shows on content types referencable by the Attached to field on the Task content type, and to show only the Tasks that are attached to the node being viewed.
    • Expand the "Advanced" pane, and click the "add" button next to Contextual Filters to add your new Contextual Filter.
    • Select the "Attached to" field (machine name: field_task_attachedto), which will be listed as "Content: Attached to (field_task_attachedto)" to use as the Contextual Filter.
    • Under When the Filter in Not Available, select the "Provide default value" radio button, and then select "Content ID from URL".
    • Under When the Filter Value is Available or a Default is Provided, check the "Specify validation criteria" radio button, select "Content" for the Validator, and then select all of the content types that can be referenced by the Attached to field on Tasks (Client, Work, etc.). 
    • Leave the select list option for Action to take if filter value does not validate to "Hide view", which is the default and the desired behavior.
    • Click the apply button to save the new contextual filter that makes the magic happen!

Basic Entity Content View Display set-up:

Configuration for Contextual Filter on Content: Attached to (field_task_attachedto):

  • Now, after saving your new View, you will see Tasks listed on the nodes that are "attached to"/referenced by Tasks. Note, there is currently a bug in Entity Views Attachment that does not automatically make the Entity Content display available on content types. First go to the "Manage fields" tab for the content types, and then go to the "Manage display" tab. You should now see the Entity Content display field for the View you created, and you can position it where you would like in relation to any other fields. Here is a shot of what a Client node should look like, after you have created the Client and an attached Task:

  • Repeat the basic process of creating the EVA View to display Tasks attached to a node for the Note and Work content types. You can also display the View in a block instead of an EVA, which will allow you to display the child content type attached to a node in the sidebar or other regions of your theme.
  • Next, create the Views to be able to display "Add new [child_content_type]" links on parent nodes. Like with displaying the child content on parent nodes, you can use an EVA or a block to display the "Add new [child_content_type]" links on the parent nodes. This example will use creating the link in an EVA for the Tasks content type, but the basic process can be repeated for Notes, Works, or any other child content types - just make sure to use the correct fields and filters applicable to the work. Finally, Entity Reference Prepopulate comes into play:
    • At admin/structure/views, click the "Add new view" link, name it something like "Add new child links" and select Show Content of type All. Uncheck create a page, and leave create a block unchecked.
    • Use the "+Add" button near the top, to add an "Entity content" display to your newly created View
    • Under the "Entity Content Settings" pane, select "Node" for the "Entity type", and select the content types that can be referenced by the "Attached to" Entity Reference field on the Task content type (e.g., Client, Work, etc.). Leave Arguments at id. I opted to not display the title of the View display by leaving "No" set for Show title.
    • Add the "Content: Nid" field to your View, and remove the Title field.
    • For your filters, set the "Content: Type" filter to show only the content types that can be referenced by your "Attached to" field on the Tasks content type.
    • Change the page options so that you only display one piece of content (which will happen automatically once you set the contextual filter for this view).
  • Now, you need to set up your contextual filter on this display so that it is used only in the context of a node which can be referenced by your "Attached to" field on the Tasks content type.
    • Expand the "Advanced" pane, and click the "add" button next to Contextual Filters to add your new Contextual Filter.
    • Select "Content: Nid", listed as "Content: Nid" to use as the Contextual Filter.
    • Under When the Filter in Not Available, select the "Provide default value" radio button, and then select "Content ID from URL".
    • Under When the Filter Value is Available or a Default is Provided, check the "Specify validation criteria" radio button, select "Content" for the Validator, and then select all of the content types that can be referenced by the Attached to field on Tasks (Client, Work, etc.). 
    • Leave the select list option for Action to take if filter value does not validate to "Hide view", which is the default and the desired behavior.
    • Click the apply button to save the new contextual filter, and then save your view.

Basic Entity Content Views Display set-up:

Contextual filter configuration:

  • The final step on this View to make it usable is to rewrite your NID field so that it is output as a link on a parent node to add a new Task node with its "Attached to" field properly referencing the parent.
    • Click on the "Content: Nid" field, and uncheck the "Create a label" box
    • Expand the "Rewrite Results" section, and check the "Rewrite the output of this field" box
    • In the Text box, enter <ul><li><a href="/node/add/task?field_task_attachedto=[nid]">Add new Task</a></li></ul>
    • In the node/add/task part of the above, 'task' is the machine name of the child content type Task, and field_task_attachedto is the Entity Reference field on the child content type that can reference the parent node being viewed. Basically, with Entity Reference Prepopulate, the above link tells Drupal to go to the create new node page for a Task with the "Attached to" field pointing to the parent node being viewed. For the Notes content type and its "Attached to" field, the rewritten link will look like <ul><li><a href="/node/add/note?field_note_attachedto=[nid]">Add new Note</a></li></ul>

Now, when viewing a parent content type like a Client, you will see the Tasks attached to that client, and a link to add a new Task node from the Client. Once the Views for the Note content type are set-up, you will see the whole deal:

Drupal version: 

Comments

golden goose

I needed to compose you the bit of observation in order to thank you very much over again relating to the beautiful things you've contributed on this page. This has been quite incredibly generous of you to make openly all that most people would've made available for an electronic book to earn some dough for their own end, most importantly considering that you could have done it if you ever decided. The techniques as well worked to be the great way to fully grasp that someone else have the identical keenness like mine to know significantly more around this condition. I am sure there are millions of more pleasant situations up front for folks who check out your site.

supreme

Thank you a lot for providing individuals with remarkably pleasant possiblity to read in detail from this blog. It is usually so terrific plus full of a good time for me and my office fellow workers to visit your website a minimum of 3 times in one week to read the latest things you have got. Not to mention, I'm just certainly impressed with all the excellent tactics served by you. Selected 2 areas on this page are in reality the most efficient we've had.

kyrie irving shoes

I actually wanted to make a word so as to express gratitude to you for all of the fabulous guidelines you are writing on this site. My long internet research has at the end been compensated with good content to write about with my pals. I would state that that many of us site visitors actually are undoubtedly fortunate to exist in a useful network with very many lovely people with beneficial plans. I feel rather happy to have used your site and look forward to plenty of more pleasurable times reading here. Thanks once again for a lot of things.

kyrie 5

I precisely had to appreciate you yet again. I am not sure the things that I would've taken care of without the type of tactics discussed by you relating to this subject matter. It seemed to be a real hard condition for me, however , considering the very professional way you managed that made me to leap with fulfillment. I'm grateful for this help and even wish you are aware of an amazing job you were accomplishing educating many people thru your webblog. Most probably you haven't encountered all of us.

adidas gazelle

I really wanted to post a small message so as to express gratitude to you for those pleasant facts you are sharing on this website. My extensive internet look up has at the end of the day been compensated with reliable facts to write about with my co-workers. I 'd believe that most of us site visitors are quite lucky to be in a superb network with very many marvellous individuals with insightful plans. I feel very much blessed to have come across your webpages and look forward to plenty of more brilliant moments reading here. Thanks a lot once again for a lot of things.

westbrook shoes

I and also my guys have already been checking out the good tactics from your web page while at once got an awful suspicion I never expressed respect to you for them. Most of the guys were as a consequence stimulated to see all of them and have in effect pretty much been making the most of them. Thanks for being well thoughtful and then for making a decision on this sort of wonderful topics millions of individuals are really desperate to understand about. Our sincere regret for not expressing appreciation to you sooner.

golden goose

I enjoy you because of your whole hard work on this web page. Gloria loves getting into investigation and it's easy to see why. Most of us know all relating to the powerful form you produce functional guidelines on your website and as well attract contribution from other ones about this subject matter then our own princess is starting to learn a whole lot. Take pleasure in the rest of the year. You are always performing a powerful job.

Add new comment | arxic Drupal

My coder is trying to persuade me to move to .net from PHP.

I have always disliked the idea because of the costs. But he's tryiong
none the less. I've been using WordPress on several websites for about a year and am anxious about switching to another
platform. I have heard excellent things about blogengine.net.
Is there a way I can transfer all my wordpress posts into it?
Any help would be really appreciated!

coach outlet

I discovered your blog web site on google and test a few of your early posts. Proceed to keep up the very good operate. I simply further up your RSS feed to my MSN Information Reader. Seeking ahead to reading extra from you in a while!?

nike air max 270

An fascinating discussion is value comment. I feel that it is best to write more on this topic, it won't be a taboo topic but typically people are not sufficient to speak on such topics. To the next. Cheers

kobe sneakers

The following time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to read, however I actually thought youd have one thing fascinating to say. All I hear is a bunch of whining about one thing that you may repair if you werent too busy searching for attention.

Add new comment | arxic Drupal

Amazing things here. I am very glad to look your article.

Thanks a lot and I'm looking forward to contact you.
Will you please drop me a e-mail?

jordans

you've got an ideal weblog right here! would you wish to make some invite posts on my weblog?

Add new comment | arxic Drupal

Awesome blog! Do you have any suggestions for aspiring writers?
I'm hoping to start my own website soon but I'm a little
lost on everything. Would you suggest starting with a free platform
like Wordpress or go for a paid option? There are so many options
out there that I'm totally overwhelmed .. Any suggestions?
Appreciate it!

Add new comment | arxic Drupal

Thank you for the good writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you! However,
how could we communicate?

bape hoodie

I found your blog web site on google and test a couple of of your early posts. Continue to maintain up the superb operate. I just additional up your RSS feed to my MSN News Reader. Searching for ahead to studying extra from you in a while!?

Add new comment | arxic Drupal

Hey! Would you mind if I share your blog with my zynga group?
There's a lot of folks that I think would really appreciate
your content. Please let me know. Thank you

balenciaga shoes

I must show some appreciation to this writer just for bailing me out of such a matter. Just after checking throughout the the web and finding solutions that were not productive, I believed my entire life was over. Living without the solutions to the problems you've sorted out all through your entire blog post is a critical case, and ones that could have adversely damaged my career if I hadn't discovered the website. Your primary mastery and kindness in dealing with all the pieces was very helpful. I'm not sure what I would've done if I had not come upon such a point like this. It's possible to at this time look forward to my future. Thanks for your time so much for your high quality and effective guide. I won't be reluctant to recommend your web page to anyone who desires guide about this subject matter.

Add new comment | arxic Drupal

I'm impressed, I have to admit. Seldom do I come across a blog that's
equally educative and interesting, and without a doubt, you have hit
the nail on the head. The issue is something not enough folks are
speaking intelligently about. I'm very happy that I stumbled across this during my hunt for something relating to this.

supreme clothing

I definitely wanted to post a simple note to appreciate you for the great hints you are showing on this website. My incredibly long internet search has now been compensated with incredibly good content to go over with my best friends. I would repeat that we site visitors are very much fortunate to exist in a useful place with so many perfect professionals with insightful tricks. I feel very much fortunate to have encountered your webpages and look forward to so many more exciting times reading here. Thanks a lot once more for all the details.

Add new comment | arxic Drupal

Hello would you mind letting me know which web host you're working with?
I've loaded your blog in 3 different internet browsers and I must say this
blog loads a lot faster then most. Can you suggest a good hosting
provider at a honest price? Many thanks, I appreciate it!

jordan shoes

I would like to point out my gratitude for your kindness supporting folks that actually need guidance on in this matter. Your real dedication to getting the message across was incredibly helpful and have really encouraged some individuals much like me to get to their aims. Your entire useful tips and hints implies much to me and further more to my colleagues. Thanks a lot; from all of us.

Add new comment | arxic Drupal

I must thank you for the efforts you've put in writing this blog.

I'm hoping to see the same high-grade blog posts from you later on as well.

In truth, your creative writing abilities has encouraged me to get my very own blog now ;)

curry 5 shoes

I really wanted to write down a brief remark in order to thank you for these lovely guides you are sharing on this website. My extended internet search has now been paid with useful facts and techniques to write about with my family and friends. I 'd assume that most of us readers actually are truly fortunate to dwell in a notable website with so many awesome professionals with interesting concepts. I feel somewhat lucky to have discovered your entire webpage and look forward to many more thrilling minutes reading here. Thanks again for a lot of things.

Add new comment | arxic Drupal

Hey there, You have done a fantastic job. I will definitely digg it and personally recommend to my friends.
I'm sure they will be benefited from this web
site.

supreme new york

I am just commenting to make you understand of the incredible encounter my friend's girl encountered using your blog. She noticed numerous details, which included how it is like to possess a wonderful giving character to have many more without problems master specified extremely tough things. You undoubtedly did more than readers' expected results. Many thanks for delivering the helpful, trusted, edifying and in addition cool thoughts on the topic to Janet.

balenciaga shoes

I'm also writing to let you know of the wonderful discovery my cousin's daughter undergone reading through your site. She even learned numerous issues, which include what it's like to have a great helping mindset to get folks clearly understand various complex subject matter. You truly surpassed her expected results. Thanks for producing these productive, healthy, edifying and also easy tips on that topic to Sandra.

Add new comment | arxic Drupal

Hello there! Do you know if they make any plugins to protect against hackers?
I'm kinda paranoid about losing everything I've worked hard on. Any recommendations?

nike max

I and my guys appeared to be taking note of the excellent things on your web blog while immediately got a terrible suspicion I had not thanked the website owner for them. Most of the ladies were for that reason warmed to see them and have without a doubt been using these things. We appreciate you indeed being very thoughtful as well as for going for some fine resources most people are really wanting to know about. Our own sincere apologies for not expressing appreciation to earlier.

Add new comment | arxic Drupal

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get three emails with the same comment.
Is there any way you can remove me from that service? Thanks a lot!

supreme shirt

My spouse and i felt absolutely excited when Raymond managed to complete his researching via the ideas he obtained from your very own web site. It's not at all simplistic just to find yourself giving for free facts which usually other people have been selling. And we fully grasp we have you to be grateful to because of that. All of the explanations you've made, the simple blog navigation, the relationships your site give support to promote - it's mostly impressive, and it is letting our son in addition to the family reckon that the theme is enjoyable, and that's particularly indispensable. Many thanks for everything!

Add new comment | arxic Drupal

I just couldn't go away your web site prior to suggesting that I
actually loved the usual info an individual provide for your visitors?

Is gonna be again steadily in order to check up on new posts

nike huarache

I definitely wanted to post a comment to express gratitude to you for all of the fabulous strategies you are posting here. My extensive internet look up has at the end been compensated with reputable concept to share with my great friends. I 'd declare that most of us visitors are very fortunate to dwell in a useful network with many special people with very helpful plans. I feel quite grateful to have used the website page and look forward to tons of more excellent moments reading here. Thank you once again for a lot of things.

golden goose outlet

I wanted to compose you one little note just to thank you very much as before for your personal precious tricks you have shared at this time. This is really unbelievably open-handed of people like you to give unreservedly all that many people could possibly have offered for sale as an e-book to end up making some bucks for their own end, most notably given that you could possibly have done it if you ever considered necessary. These principles as well acted as the great way to be certain that many people have similar dream similar to my personal own to learn a little more with respect to this issue. I am certain there are thousands of more enjoyable opportunities in the future for individuals that read your website.

golden goose

I have to show my appreciation to you for bailing me out of this type of issue. Because of surfing around throughout the world wide web and getting methods which are not helpful, I assumed my life was gone. Existing minus the approaches to the difficulties you have sorted out all through your entire short article is a critical case, and the ones which could have in a negative way damaged my entire career if I hadn't come across your blog. Your own personal understanding and kindness in playing with the whole thing was very helpful. I am not sure what I would have done if I had not come upon such a point like this. I can also at this time relish my future. Thanks a lot very much for this skilled and amazing guide. I won't think twice to endorse the sites to any individual who needs to have guidance on this matter.

cheap jordans

Needed to post you this very little note so as to give many thanks over again regarding the incredible basics you have provided on this website. It's so unbelievably generous with you to make openly exactly what numerous people would have advertised for an e-book to end up making some cash for their own end, mostly now that you might have done it if you desired. Those techniques also served like a great way to fully grasp that other individuals have a similar dream similar to my own to know a little more around this matter. I am sure there are several more enjoyable situations ahead for folks who see your website.

Add new comment | arxic Drupal

What i do not understood is in reality how you are no longer actually much
more well-favored than you may be right now.
You're so intelligent. You know thus considerably in relation to this
matter, made me for my part imagine it from a
lot of various angles. Its like men and women aren't interested unless it's one thing to
do with Girl gaga! Your personal stuffs great. Always care for it
up!

fila

I as well as my guys appeared to be reading the best secrets located on the blog then the sudden I got a terrible suspicion I never expressed respect to the web blog owner for those techniques. Those young men happened to be so stimulated to read all of them and already have definitely been tapping into those things. I appreciate you for truly being indeed considerate as well as for utilizing varieties of fantastic things millions of individuals are really desirous to know about. My personal sincere apologies for not expressing appreciation to earlier.

Add new comment | arxic Drupal

Outstanding post however I was wondering if you could write a litte more on this subject?
I'd be very thankful if you could elaborate a little bit more.
Cheers!

kyrie 5

I am glad for commenting to make you know of the fantastic experience my child obtained using yuor web blog. She figured out several details, including what it is like to have an ideal teaching spirit to get men and women really easily fully grasp several extremely tough subject matter. You actually did more than visitors' expected results. Thanks for imparting those good, dependable, informative not to mention easy tips about your topic to Julie.

Add new comment | arxic Drupal

It is the best time to make a few plans for the future and it is time to be happy.
I've read this put up and if I may just I wish to recommend
you some interesting issues or suggestions. Maybe you could write subsequent articles referring
to this article. I desire to learn more issues about it!

Pages

Add new comment