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

balenciaga trainers

Thank you a lot for providing individuals with such a brilliant possiblity to discover important secrets from here. It can be so great and full of a good time for me and my office fellow workers to visit your site at minimum three times per week to study the latest secrets you have. And definitely, I'm just actually happy with your excellent information served by you. Selected 2 ideas in this posting are completely the most impressive we have all ever had.

Add new comment | arxic Drupal

Hey this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience.

Any help would be greatly appreciated!

kyrie 3 shoes

I wish to show some thanks to you just for rescuing me from such a dilemma. Just after looking out throughout the the net and coming across methods that were not productive, I figured my life was over. Being alive devoid of the answers to the problems you've sorted out as a result of this guide is a crucial case, as well as the kind which may have negatively damaged my entire career if I had not encountered the blog. The ability and kindness in dealing with all things was vital. I am not sure what I would have done if I hadn't come upon such a stuff like this. I can at this moment look forward to my future. Thank you very much for the specialized and sensible help. I won't be reluctant to endorse your blog post to anyone who needs to have tips on this subject.

longchamp bags

My spouse and i ended up being so fulfilled when Raymond could carry out his preliminary research through your ideas he received from your very own site. It's not at all simplistic to simply happen to be giving for free guidelines which often the others may have been selling. We really see we now have the website owner to be grateful to for this. All of the illustrations you have made, the straightforward site menu, the friendships you help create - it's all fantastic, and it's making our son and our family do think that situation is brilliant, which is certainly really pressing. Thank you for everything!

Add new comment | arxic Drupal

Hello terrific blog! Does running a blog such as this
require a great deal of work? I have virtually no expertise in programming however I had
been hoping to start my own blog soon. Anyhow, if you have any ideas or tips for new blog owners
please share. I understand this is off subject nevertheless
I simply had to ask. Kudos!

goyard

My husband and i ended up being absolutely peaceful when Louis could deal with his studies from your ideas he gained out of your site. It is now and again perplexing to simply always be making a gift of tips and tricks which the rest could have been trying to sell. And we acknowledge we've got the blog owner to give thanks to for that. All the explanations you've made, the straightforward website navigation, the friendships you can give support to foster - it is all fabulous, and it's leading our son and the family do think that topic is exciting, and that's wonderfully pressing. Thank you for the whole thing!

vapormax

I definitely wanted to make a remark to say thanks to you for the great information you are sharing on this site. My time consuming internet search has at the end been recognized with incredibly good suggestions to share with my family members. I would assume that many of us website visitors are undoubtedly endowed to exist in a superb network with very many lovely people with valuable points. I feel very much lucky to have discovered your web pages and look forward to plenty of more entertaining moments reading here. Thank you once again for all the details.

Add new comment | arxic Drupal

I'm amazed, I have to admit. Seldom do I come across a blog that's both equally educative and
engaging, and without a doubt, you've hit the nail on the head.
The problem is something too few men and women are speaking intelligently about.
I am very happy I found this during my search for something concerning this.

off white hoodie

I would like to convey my passion for your kind-heartedness for individuals who really want guidance on that concept. Your very own commitment to getting the solution up and down appeared to be definitely useful and has constantly permitted many people just like me to achieve their endeavors. Your own helpful guide can mean a lot a person like me and extremely more to my peers. Best wishes; from each one of us.

Add new comment | arxic Drupal

Unquestionably believe that which you said. Your favorite justification seemed to be on the internet the easiest
thing to be aware of. I say to you, I certainly get irked while people think
about worries that they just don't know about. You managed to hit the nail upon the top as well as
defined out the whole thing without having side effect , people can take a signal.
Will probably be back to get more. Thanks

yeezy boost 700

I and my pals were actually analyzing the nice tips and tricks on your web page then all of the sudden got an awful feeling I had not expressed respect to the site owner for those techniques. My ladies are actually as a result glad to read through them and have in effect absolutely been taking pleasure in those things. We appreciate you simply being simply accommodating as well as for finding this form of incredible guides millions of individuals are really desperate to be aware of. My honest apologies for not expressing gratitude to you earlier.

coach purse

Thank you so much for providing individuals with an exceptionally memorable possiblity to read in detail from here. It is usually so enjoyable and packed with amusement for me and my office acquaintances to search the blog particularly thrice in 7 days to read the newest stuff you will have. And lastly, I am just actually contented with all the fantastic creative ideas you serve. Selected 4 facts in this post are ultimately the best I've ever had.

Add new comment | arxic Drupal

Hi, Neat post. There is a problem together with your website in web explorer, may test this?
IE still is the market chief and a good portion of folks will omit your magnificent writing
due to this problem.

coach purse

Thanks so much for giving everyone a very nice possiblity to read in detail from this website. It is always very brilliant and as well , stuffed with fun for me personally and my office mates to search your blog at least thrice in one week to see the new secrets you will have. Of course, I am just always astounded with all the powerful creative ideas you give. Some 4 points on this page are absolutely the best we have all ever had.

michael kors

I and also my buddies have already been reviewing the excellent techniques located on your web page and so unexpectedly got an awful feeling I had not thanked the site owner for those strategies. Those men became certainly passionate to read all of them and have now seriously been using them. Appreciate your simply being indeed helpful as well as for utilizing such essential themes millions of individuals are really desperate to discover. Our sincere regret for not expressing gratitude to you earlier.

Add new comment | arxic Drupal

Its such as you learn my mind! You seem to understand a lot about this, such as you wrote the ebook in it or something.

I believe that you could do with a few p.c.

to pressure the message house a little bit, however other
than that, that is fantastic blog. A fantastic read.
I will certainly be back.

Add new comment | arxic Drupal

Great website. Lots of helpful info here. I am sending it to a
few pals ans additionally sharing in delicious.

And of course, thank you on your effort!

Add new comment | arxic Drupal

My brother recommended I may like this web site. He was
once totally right. This put up truly made my day. You cann't imagine just
how so much time I had spent for this info!

Thank you!

Add new comment | arxic Drupal

I am curious to find out what blog system
you are utilizing? I'm having some small security
problems with my latest website and I would like to find something more safeguarded.
Do you have any solutions?

hogan outlet online

Can I simply say what a aid to search out somebody who actually knows what theyre talking about on the internet. You definitely know learn how to bring a problem to light and make it important. Extra folks need to read this and understand this side of the story. I cant consider youre no more in style since you undoubtedly have the gift.

Add new comment | arxic Drupal

You have made some good points there. I checked on the net for
more info about the issue and found most people
will go along with your views on this site.

nike cortez

When I initially commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get 4 emails with the same comment. Is there any method you can remove me from that service? Thanks!

Add new comment | arxic Drupal

With havin so much content do you ever run into any problems of plagorism or copyright violation? My blog has a lot of unique content I've either created myself or outsourced but
it looks like a lot of it is popping it up all over the internet without my permission. Do you know any ways to help stop content from being stolen? I'd definitely appreciate it.

hermes

It is best to take part in a contest for one of the best blogs on the web. I will recommend this web site!

kevin durant shoes

After I originally commented I clicked the -Notify me when new feedback are added- checkbox and now every time a comment is added I get 4 emails with the identical comment. Is there any means you'll be able to remove me from that service? Thanks!

Add new comment | arxic Drupal

Hello my family member! I wish to say that this article is awesome, nice written and come with
approximately all significant infos. I would like to peer extra posts like this .

off white

There are some fascinating points in time on this article however I don抰 know if I see all of them middle to heart. There's some validity however I will take maintain opinion till I look into it further. Good article , thanks and we want extra! Added to FeedBurner as properly

Add new comment | arxic Drupal

I think what you posted made a great deal of sense.
However, think on this, what if you typed a catchier title?

I mean, I don't wish to tell you how to run your blog, however
suppose you added a headline that grabbed folk's attention? I mean Add new comment | arxic Drupal is a little vanilla.
You might look at Yahoo's home page and note how
they create article headlines to grab viewers to click. You might try
adding a video or a related pic or two to grab readers interested
about what you've got to say. Just my opinion, it would make your posts a
little bit more interesting.

kobe shoes

I intended to create you this very small remark in order to give thanks yet again relating to the pretty guidelines you've featured here. It has been simply open-handed with you to convey easily exactly what a few people would have distributed as an e-book to help make some money for their own end, most importantly given that you might have done it if you decided. Those tips in addition acted to be a good way to understand that other individuals have the identical eagerness the same as my very own to grasp whole lot more with regard to this issue. I'm certain there are lots of more fun moments up front for people who looked at your blog.

Add new comment | arxic Drupal

Howdy! This post could not be written any better! Reading through this post reminds me
of my previous room mate! He always kept talking about this.
I will forward this article to him. Pretty sure he will have a good read.
Many thanks for sharing!

kobe shoes

My spouse and i ended up being quite thrilled that Louis managed to complete his analysis using the precious recommendations he received when using the web pages. It's not at all simplistic to simply be making a gift of tips and hints that many some people might have been making money from. And we all recognize we now have the website owner to thank because of that. Most of the illustrations you've made, the straightforward site menu, the relationships you will give support to promote - it's got most remarkable, and it's leading our son and the family believe that this concept is satisfying, and that is pretty important. Many thanks for everything!

Add new comment | arxic Drupal

When someone writes an post he/she maintains the image of a
user in his/her mind that how a user can know it.
Thus that's why this piece of writing is amazing.
Thanks!

balenciaga shoes

I precisely wanted to appreciate you again. I am not sure the things that I would've taken care of without the entire tips contributed by you concerning this problem. It was an absolute fearsome dilemma in my position, however , discovering this well-written manner you solved the issue forced me to cry over gladness. I'm grateful for the assistance and as well , expect you recognize what a great job your are providing instructing many others all through a web site. More than likely you haven't come across any of us.

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.

Pages

Add new comment