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

birkin bag

I simply wanted to post a small comment in order to thank you for the remarkable suggestions you are giving out at this site. My rather long internet investigation has at the end been compensated with reputable know-how to go over with my pals. I would assert that many of us readers are really lucky to dwell in a fine place with many brilliant people with great advice. I feel quite happy to have seen the website page and look forward to some more entertaining moments reading here. Thank you once again for everything.

curry 5

I have to express thanks to the writer for bailing me out of this particular situation. Right after scouting throughout the search engines and obtaining concepts which were not helpful, I figured my life was well over. Living without the approaches to the issues you've solved by means of the blog post is a serious case, and the kind that might have badly affected my entire career if I had not encountered your web blog. Your own personal capability and kindness in dealing with the whole thing was vital. I am not sure what I would have done if I had not come across such a stuff like this. I can also at this moment relish my future. Thank you so much for this impressive and results-oriented guide. I will not think twice to endorse the blog to any person who will need tips on this topic.

nike air max 90

I wanted to compose you that very little observation just to thank you very much once again with your lovely things you have provided in this article. It is so pretty generous of you giving easily all that many individuals would've made available as an electronic book to earn some money for their own end, principally considering that you might well have tried it if you ever desired. Those solutions additionally worked to provide a easy way to realize that other individuals have similar interest much like my own to see more when considering this problem. I am sure there are numerous more pleasant occasions in the future for many who scan through your blog post.

Add new comment | arxic Drupal

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

balenciaga shoes

I intended to compose you the very little word just to say thank you the moment again with your pleasing strategies you have shared here. It was simply wonderfully generous of people like you to present unhampered all a few people would have offered as an e-book in making some cash for themselves, even more so considering that you could possibly have done it in the event you decided. The concepts also acted as a easy way to be aware that other people online have the same dream just like my very own to grasp somewhat more pertaining to this matter. I am sure there are numerous more pleasurable situations ahead for many who read your website.

Add new comment | arxic Drupal

I know this if off topic but I'm looking into starting my
own blog and was wondering what all is required to get set up?

I'm assuming having a blog like yours would cost a pretty penny?
I'm not very internet smart so I'm not 100% sure.
Any suggestions or advice would be greatly appreciated.
Cheers

air max

Thanks so much for providing individuals with remarkably terrific chance to read from this web site. It's usually very excellent plus stuffed with a good time for me personally and my office peers to search your web site at the very least three times per week to see the newest items you have got. And indeed, I'm just at all times contented for the tremendous suggestions served by you. Certain 2 facts in this article are easily the most effective we have ever had.

Add new comment | arxic Drupal

I've been surfing online more than three hours
today, yet I never found any interesting article like yours.
It's pretty worth enough for me. Personally, if all web owners and bloggers
made good content as you did, the net will be much more useful
than ever before.

nike air force 1 low

I wish to voice my love for your generosity supporting those individuals that really need help on this important concept. Your very own dedication to passing the message around had become particularly advantageous and have continually permitted guys like me to get to their goals. This warm and friendly publication implies a lot to me and substantially more to my office colleagues. Thanks a ton; from each one of us.

Add new comment | arxic Drupal

What i don't realize is if truth be told how you are now not actually much more
well-appreciated than you might be now. You're so intelligent.

You already know therefore significantly in relation to this subject, made me individually believe it from so many various angles.
Its like men and women don't seem to be involved except it's something to accomplish with Woman gaga!

Your own stuffs excellent. At all times handle it up!

yeezy

I actually wanted to write a small note to be able to appreciate you for these remarkable guides you are giving out on this site. My particularly long internet look up has now been honored with sensible facts and techniques to go over with my friends. I would express that we visitors are truly blessed to exist in a fabulous site with many perfect individuals with valuable secrets. I feel very much grateful to have encountered your entire website and look forward to plenty of more brilliant minutes reading here. Thanks a lot once again for everything.

Add new comment | arxic Drupal

Hello, Neat post. There is a problem together with your site in web explorer, may check this?

IE still is the market leader and a good element of other people
will omit your great writing because of this problem.

hermes belt

Needed to write you one little observation to be able to give many thanks as before regarding the spectacular thoughts you have discussed in this article. It has been so extremely generous of people like you to allow publicly precisely what a number of people would have offered for an e-book to earn some dough for themselves, most importantly seeing that you might have done it in case you decided. These guidelines additionally acted to be the fantastic way to realize that the rest have the identical dream like my very own to figure out way more around this condition. I believe there are thousands of more enjoyable times up front for individuals who look into your site.

vans outlet

I wish to convey my respect for your generosity for persons that really need help on your situation. Your special commitment to getting the message throughout appears to be remarkably powerful and has all the time allowed others like me to realize their goals. Your helpful hints and tips indicates this much a person like me and even more to my peers. Thank you; from each one of us.

Add new comment | arxic Drupal

Hello everyone, it's my first pay a visit at this web site, and paragraph is in fact fruitful designed for
me, keep up posting such articles or reviews.

curry 4

I wish to point out my respect for your generosity for men and women who should have help with that area. Your real dedication to passing the solution around became particularly advantageous and has regularly enabled professionals just like me to achieve their ambitions. Your new warm and friendly report can mean a lot to me and extremely more to my peers. Warm regards; from everyone of us.

Add new comment | arxic Drupal

You are so cool! I don't think I have read through a single thing
like that before. So good to find another person with a few unique
thoughts on this subject matter. Really.. thanks for starting
this up. This web site is one thing that is needed on the web,
someone with a bit of originality!

coach outlet store

I would like to express my appreciation for your kind-heartedness for men who should have help on this one matter. Your personal dedication to passing the message along was extremely beneficial and have continually allowed most people just like me to get to their aims. Your personal insightful advice indicates much a person like me and a whole lot more to my fellow workers. Best wishes; from everyone of us.

Add new comment | arxic Drupal

Hey terrific blog! Does running a blog such as this take a great
deal of work? I have virtually no expertise in computer programming however I had been hoping
to start my own blog in the near future. Anyhow, if you have any suggestions or tips for new blog owners please share.
I understand this is off topic but I simply wanted to ask.
Thank you!

nike foamposite

I simply had to thank you so much once again. I do not know the things that I would have undertaken in the absence of the type of tips revealed by you regarding such a subject. It was a very hard scenario in my opinion, but taking note of a specialised strategy you dealt with the issue forced me to jump for gladness. Extremely thankful for this work as well as pray you are aware of a powerful job that you are doing instructing the rest using your blog post. I'm certain you've never met any of us.

Add new comment | arxic Drupal

Hi exceptional blog! Does running a blog similar to this take a great deal of work?
I've absolutely no knowledge of coding but I had been hoping to start my own blog
in the near future. Anyhow, should you have any ideas or tips for new blog owners please share.

I understand this is off topic however I simply had to ask.

Thank you!

kyrie 4

I would like to convey my passion for your kindness for individuals that really need help on your question. Your personal commitment to passing the message across came to be certainly effective and has in most cases made guys much like me to get to their ambitions. Your personal useful key points entails a whole lot a person like me and further more to my peers. Many thanks; from each one of us.

Add new comment | arxic Drupal

Hey I know this is off topic but I was wondering if you knew of
any widgets I could add to my blog that automatically tweet my newest twitter updates.
I've been looking for a plug-in like this for quite some time and was hoping maybe
you would have some experience with something like this.
Please let me know if you run into anything. I truly enjoy reading your blog and I
look forward to your new updates.

kd 12

I not to mention my buddies were actually looking through the great items from your website and before long got a terrible feeling I had not thanked the website owner for them. All the men are already for that reason glad to see them and have in effect honestly been taking pleasure in those things. Appreciation for really being simply helpful and also for opting for such incredibly good information millions of individuals are really wanting to know about. My very own honest apologies for not expressing appreciation to you earlier.

golden goose

I wanted to create you a tiny remark just to give thanks as before with your unique information you've featured in this article. It's surprisingly open-handed of you to allow unhampered what exactly a number of us could possibly have made available as an ebook to earn some money for themselves, particularly now that you could have tried it if you ever wanted. The concepts as well worked to be the good way to realize that other people have a similar interest like my own to realize good deal more related to this issue. I know there are lots of more pleasurable instances in the future for many who read your blog.

Add new comment | arxic Drupal

Hi, Neat post. There is an issue along with your web site in internet explorer,
may check this? IE still is the market chief and a big component to other folks
will miss your fantastic writing due to this problem.

nike air vapormax

Thank you for your entire hard work on this web site. My mom delights in carrying out internet research and it is easy to understand why. Most people notice all relating to the dynamic form you render very helpful things on this website and therefore cause participation from people on the subject matter plus our own daughter is being taught a whole lot. Take advantage of the remaining portion of the year. Your carrying out a splendid job.

Add new comment | arxic Drupal

Howdy! I know this is kind of off topic but I was wondering which blog platform are you using for this
site? I'm getting fed up of Wordpress because I've had issues with hackers and I'm looking at alternatives for another platform.

I would be fantastic if you could point me in the
direction of a good platform.

Add new comment | arxic Drupal

Wonderful beat ! I wish to apprentice whilst you amend
your web site, how could i subscribe for a weblog website?
The account aided me a acceptable deal. I had been a little bit familiar of this your broadcast offered shiny transparent idea

Add new comment | arxic Drupal

Hi would you mind letting me know which web
host you're using? I've loaded your blog in 3 completely different
web browsers and I must say this blog loads a lot quicker then most.
Can you suggest a good internet hosting provider at a
reasonable price? Cheers, I appreciate it!

kyrie shoes

This web page can be a walk-by way of for all of the info you wanted about this and didn抰 know who to ask. Glimpse right here, and you抣l undoubtedly uncover it.

Add new comment | arxic Drupal

I'm really enjoying the theme/design of your blog.

Do you ever run into any internet browser compatibility issues?
A few of my blog visitors have complained about my blog not operating correctly in Explorer but looks great in Opera.

Do you have any solutions to help fix this issue?

nike shox for men

Oh my goodness! a tremendous article dude. Thanks Nonetheless I'm experiencing subject with ur rss . Don抰 know why Unable to subscribe to it. Is there anybody getting equivalent rss downside? Anybody who knows kindly respond. Thnkx

Add new comment | arxic Drupal

I am really impressed with your writing skills and also with the layout on your blog.
Is this a paid theme or did you customize it yourself?
Anyway keep up the excellent quality writing, it's rare to see
a nice blog like this one today.

Add new comment | arxic Drupal

I know this site provides quality dependent articles or reviews and additional data,
is there any other web page which gives these information in quality?

golden goose

The subsequent time I learn a blog, I hope that it doesnt disappoint me as a lot as this one. I mean, I do know it was my option to read, but I really thought youd have something fascinating to say. All I hear is a bunch of whining about something that you could possibly repair when you werent too busy in search of attention.

Add new comment | arxic Drupal

Excellent blog you have here.. It's difficult to find high-quality writing like yours nowadays.
I seriously appreciate people like you! Take care!!

michael kors outlet

I抦 impressed, I need to say. Actually hardly ever do I encounter a blog that抯 each educative and entertaining, and let me tell you, you've hit the nail on the head. Your thought is excellent; the problem is something that not sufficient persons are talking intelligently about. I'm very completely happy that I stumbled across this in my seek for something referring to this.

Add new comment | arxic Drupal

This is a good tip particularly to those fresh to
the blogosphere. Brief but very accurate information… Many thanks
for sharing this one. A must read post!

nike kd 12

I and my guys came checking out the nice tips found on your web page and immediately I got a horrible suspicion I had not thanked the site owner for those tips. All the people appeared to be as a consequence excited to read through all of them and already have quite simply been taking advantage of them. We appreciate you getting very kind and then for having such good issues most people are really desperate to be informed on. Our sincere apologies for not saying thanks to you sooner.

curry 6

I precisely wanted to thank you very much again. I'm not certain what I would have gone through without the actual techniques contributed by you concerning such a situation. Previously it was a very distressing matter for me, but viewing the professional technique you handled that made me to leap for contentment. Extremely happy for your support as well as hope you comprehend what a powerful job that you're carrying out instructing men and women all through your web blog. I know that you have never encountered any of us.

Pages

Add new comment