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

adidas yeezy

I have to voice my admiration for your kind-heartedness giving support to folks who absolutely need assistance with this one area of interest. Your special commitment to getting the message around appears to be definitely significant and has specifically encouraged guys like me to attain their ambitions. Your entire important useful information entails so much a person like me and somewhat more to my colleagues. Thanks a lot; from everyone of us.

nike air max 2017

I needed to compose you a little bit of note just to thank you once again just for the pretty views you've contributed on this site. It has been particularly open-handed of people like you to allow extensively exactly what many of us could have offered as an e book in making some bucks for their own end, precisely now that you might well have tried it if you decided. Those tactics additionally served to be a good way to understand that someone else have the identical dream just as my personal own to see whole lot more on the subject of this problem. I believe there are lots of more pleasant situations in the future for people who read your blog.

supreme new york

My wife and i felt absolutely peaceful Emmanuel could conclude his studies from your ideas he came across from your very own blog. It's not at all simplistic to simply be giving for free things which often men and women may have been trying to sell. We do understand we've got the website owner to thank because of that. All of the illustrations you made, the straightforward site menu, the friendships you can help foster - it's most spectacular, and it's aiding our son and our family feel that the situation is interesting, and that is extremely serious. Thanks for all the pieces!

Add new comment | arxic Drupal

It's really a cool and useful piece of information. I'm happy that you simply shared this useful
info with us. Please keep us up to date like this. Thanks for sharing.

yeezy boost 350 v2

I simply had to thank you very much all over again. I do not know what I might have created in the absence of the basics shared by you over such a area. It had become a hard concern in my position, however , being able to view the very skilled approach you handled that forced me to cry for delight. I am grateful for this work and as well , hope you find out what a great job that you are undertaking instructing some other people via your blog post. I am certain you have never come across any of us.

Add new comment | arxic Drupal

I have been browsing on-line more than three hours
these days, yet I never discovered any fascinating article like
yours. It is lovely price enough for me. In my opinion, if all webmasters and bloggers made excellent content material as
you probably did, the net will probably be a lot more helpful than ever before.

lebron 15

Thanks for all of the work on this web site. Gloria really loves carrying out investigations and it's really simple to grasp why. My partner and i hear all relating to the lively method you provide great tips and hints via this web site and encourage participation from the others on the matter so our princess has always been studying so much. Take pleasure in the remaining portion of the year. You're performing a fantastic job.

Add new comment | arxic Drupal

Hi! I could have sworn I've been to this website before but after browsing through
some of the articles I realized it's new to me.

Anyhow, I'm certainly happy I discovered it and I'll be
book-marking it and checking back frequently!

lebron 17

A lot of thanks for all of the labor on this web page. Ellie delights in carrying out research and it's obvious why. I notice all concerning the compelling mode you provide very useful guides by means of the web site and as well as invigorate response from website visitors on that subject matter while our own child is understanding a great deal. Take pleasure in the rest of the year. You're the one carrying out a wonderful job.

timberland outlet

I simply wanted to type a simple word so as to thank you for all the great secrets you are sharing on this site. My particularly long internet look up has finally been paid with brilliant points to exchange with my companions. I would point out that most of us visitors actually are unequivocally fortunate to be in a really good site with many special professionals with valuable tricks. I feel extremely blessed to have encountered the web site and look forward to really more cool moments reading here. Thank you once more for a lot of things.

Add new comment | arxic Drupal

Hello! I know this is kinda off topic but I'd figured I'd ask.
Would you be interested in trading links or maybe guest writing a blog article or vice-versa?
My blog discusses a lot of the same topics as yours and I think we could greatly benefit from each other.

If you're interested feel free to shoot me an email.
I look forward to hearing from you! Excellent blog by the way!

nike air vapormax

I want to show my appreciation for your kind-heartedness in support of women who actually need assistance with this particular topic. Your special dedication to getting the message all through came to be exceedingly informative and has frequently allowed associates just like me to achieve their aims. Your amazing important instruction signifies a whole lot a person like me and even more to my fellow workers. Regards; from each one of us.

Add new comment | arxic Drupal

When someone writes an paragraph he/she maintains the plan of a user
in his/her mind that how a user can be aware of it. Thus that's why
this article is great. Thanks!

golden goose outlet

Needed to draft you the tiny remark in order to say thank you the moment again for those splendid ideas you've contributed here. This is quite pretty generous with people like you to give unhampered exactly what most of us could possibly have offered for an e-book in making some money on their own, primarily given that you could have tried it in case you desired. The thoughts likewise acted as a good way to realize that some people have the same dream similar to mine to find out many more in respect of this issue. I am sure there are lots of more enjoyable situations up front for those who look over your website.

timberland boots

I precisely needed to thank you so much once again. I'm not certain the things I could possibly have used in the absence of the type of strategies contributed by you concerning my subject matter. It absolutely was the hard dilemma for me, nevertheless coming across the very specialised manner you resolved the issue took me to weep over fulfillment. I'm just grateful for the information and then pray you find out what an amazing job you are getting into teaching many others through a blog. I'm certain you haven't met all of us.

supreme new york

Thanks for your whole effort on this site. Kate really loves making time for internet research and it's really easy to understand why. A number of us hear all about the powerful manner you render very important techniques on this website and therefore encourage contribution from others on the point while our own daughter is now discovering a great deal. Have fun with the remaining portion of the year. You have been carrying out a glorious job.

supreme shirt

Needed to create you the tiny note so as to thank you very much as before considering the amazing advice you have contributed on this page. It has been certainly pretty open-handed of people like you to supply openly exactly what most people might have sold for an ebook to make some dough for their own end, most importantly considering that you could have done it if you ever decided. Those things additionally acted to become good way to know that someone else have the identical fervor the same as my own to figure out significantly more with respect to this issue. Certainly there are a lot more fun opportunities up front for individuals that read carefully your website.

Add new comment | arxic Drupal

With havin so much content do you ever run into any issues of plagorism or copyright violation? My website has a lot of exclusive content I've either
written myself or outsourced but it appears a lot of it is popping it up all over
the internet without my authorization. Do you know any techniques to help reduce content from being stolen? I'd definitely appreciate it.

mbt

I just wanted to compose a quick note in order to appreciate you for these nice tricks you are giving at this website. My prolonged internet investigation has at the end been paid with excellent insight to go over with my partners. I 'd repeat that most of us site visitors are extremely lucky to dwell in a wonderful place with very many marvellous professionals with valuable things. I feel very happy to have discovered your web pages and look forward to really more fun moments reading here. Thanks once again for a lot of things.

off white hoodie

I together with my pals have already been examining the excellent pointers found on your web blog while instantly I got a terrible feeling I had not expressed respect to the site owner for those strategies. All of the guys became happy to learn all of them and now have simply been taking advantage of those things. I appreciate you for being considerably thoughtful as well as for obtaining varieties of really good subjects most people are really needing to understand about. My very own honest apologies for not expressing appreciation to you sooner.

Add new comment | arxic Drupal

Howdy! This is my first comment here so I just wanted
to give a quick shout out and say I genuinely enjoy reading your
blog posts. Can you suggest any other blogs/websites/forums that cover the same topics?
Thanks a lot!

curry 6

I have to point out my love for your kind-heartedness giving support to individuals who should have assistance with your study. Your real commitment to passing the message all-around became wonderfully invaluable and have truly empowered associates much like me to realize their aims. Your own informative recommendations can mean a whole lot to me and further more to my office colleagues. Thanks a lot; from each one of us.

Add new comment | arxic Drupal

I was suggested this blog by means of my cousin. I'm
now not sure whether or not this submit is written by way of
him as no one else recognise such specific about my difficulty.
You're incredible! Thanks!

westbrook shoes

I used to be very happy to find this net-site.I wanted to thanks on your time for this glorious learn!! I definitely having fun with every little bit of it and I have you bookmarked to check out new stuff you blog post.

Add new comment | arxic Drupal

Howdy very cool web site!! Guy .. Beautiful .. Amazing
.. I will bookmark your site and take the feeds additionally?
I'm satisfied to find so many useful information here in the publish, we'd like work out
extra strategies in this regard, thank you for sharing. . .
. . .

chrome hearts outlet

I found your blog website on google and examine a couple of of your early posts. Proceed to maintain up the superb operate. I simply further up your RSS feed to my MSN Information Reader. Seeking ahead to reading more from you afterward!?

hermes belts

I'm typically to blogging and i actually respect your content. The article has really peaks my interest. I am going to bookmark your website and hold checking for new information.

kd 12

Spot on with this write-up, I actually think this web site needs way more consideration. I抣l in all probability be once more to read far more, thanks for that info.

Add new comment | arxic Drupal

Hey there! I just wanted to ask if you ever
have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing
months of hard work due to no backup. Do you have any
solutions to stop hackers?

golden goose

Can I simply say what a aid to search out someone who truly knows what theyre talking about on the internet. You definitely know learn how to carry an issue to mild and make it important. More individuals need to read this and understand this side of the story. I cant consider youre no more common since you positively have the gift.

Add new comment | arxic Drupal

I wanted to thank you for this excellent read!!

I definitely enjoyed every little bit of it. I have got you book marked to look at
new stuff you post…

jordan shoes

When I originally commented I clicked the -Notify me when new feedback are added- checkbox and now every time a comment is added I get four emails with the identical comment. Is there any approach you can take away me from that service? Thanks!

longchamp handbags

This site is mostly a walk-via for all the information you needed about this and didn抰 know who to ask. Glimpse right here, and also you抣l positively uncover it.

Add new comment | arxic Drupal

you are truly a just right webmaster. The web site loading speed is incredible.
It kind of feels that you are doing any unique trick.
Furthermore, The contents are masterwork. you have performed a magnificent job in this matter!

Pages

Add new comment