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

Add new comment | arxic Drupal

Ahaa, its fastidious dialogue on the topic of this article at this place at this blog, I
have read all that, so at this time me also commenting
here.

michael kors factory outlet

I want to show appreciation to you for bailing me out of this type of crisis. Right after checking throughout the world-wide-web and coming across opinions which were not powerful, I was thinking my life was over. Living without the presence of strategies to the difficulties you've resolved by means of your good blog post is a serious case, as well as ones which might have in a negative way damaged my entire career if I had not noticed your web blog. Your personal understanding and kindness in maneuvering the whole lot was vital. I am not sure what I would've done if I hadn't come across such a point like this. I am able to at this point look forward to my future. Thanks very much for the expert and result oriented help. I won't hesitate to refer the website to any individual who should get tips about this situation.

yeezy

I in addition to my pals came looking at the best things on the website while instantly I had a terrible feeling I had not thanked you for those techniques. All the people came for that reason joyful to read through all of them and already have seriously been tapping into those things. Thank you for turning out to be simply considerate and then for using such incredibly good resources millions of individuals are really desirous to be aware of. Our honest apologies for not expressing appreciation to you sooner.

Add new comment | arxic Drupal

Hi! I could have sworn I've visited this blog before
but after browsing through many of the articles I realized it's new to me.
Regardless, I'm certainly delighted I found it and I'll be book-marking it and checking
back regularly!

supreme

I want to express my affection for your generosity supporting those people who need assistance with in this concern. Your personal commitment to passing the message all over came to be astonishingly advantageous and has truly made employees like me to reach their aims. Your entire insightful advice can mean a whole lot a person like me and far more to my mates. Best wishes; from all of us.

coach facotory outlet

I want to show thanks to you just for rescuing me from this difficulty. After scouting through the the web and seeing tricks that were not powerful, I figured my life was done. Being alive devoid of the approaches to the problems you have sorted out all through your entire write-up is a crucial case, as well as the ones that could have adversely affected my entire career if I had not discovered your web site. Your ability and kindness in playing with all the stuff was useful. I don't know what I would've done if I hadn't come across such a step like this. I'm able to at this moment look forward to my future. Thanks for your time very much for your reliable and sensible help. I will not hesitate to propose your web sites to any individual who needs and wants guidelines about this subject matter.

Add new comment | arxic Drupal

Heya! I realize this is kind of off-topic but I needed to ask.

Does operating a well-established blog such as yours take a massive amount work?
I am brand new to running a blog however I do write in my diary daily.
I'd like to start a blog so I can easily share my personal experience and thoughts online.
Please let me know if you have any recommendations or tips for new aspiring blog owners.

Appreciate it!

louboutin shoes

Thanks a lot for providing individuals with such a pleasant chance to read articles and blog posts from this blog. It is usually so sweet and packed with a lot of fun for me personally and my office mates to visit your website at a minimum three times weekly to read through the newest secrets you will have. And of course, I am at all times pleased concerning the exceptional concepts you serve. Certain 3 tips in this posting are basically the most impressive we have all had.

yeezy boost

Thanks for all of your efforts on this blog. My mom really loves participating in research and it's easy to understand why. Many of us notice all about the lively ways you produce reliable tactics through this web blog and as well strongly encourage contribution from other people on the article so my simple princess is always learning so much. Take advantage of the remaining portion of the new year. Your conducting a wonderful job.

Add new comment | arxic Drupal

great points altogether, you simply won a emblem new reader.
What may you recommend in regards to your post that you just
made a few days in the past? Any positive?

adidas tubular

I together with my buddies have been going through the excellent recommendations from the blog and unexpectedly developed a terrible feeling I had not thanked the web site owner for those tips. Those boys became so very interested to read them and have now actually been taking pleasure in them. I appreciate you for actually being quite accommodating and for considering these kinds of good resources most people are really needing to know about. Our own sincere regret for not expressing appreciation to you earlier.

Add new comment | arxic Drupal

Great post. I was checking continuously this blog and I am impressed!
Very useful information particularly the ultimate part :) I take care
of such information a lot. I used to be seeking this certain info for a long
time. Thank you and good luck.

hermes handbags

I would like to express thanks to you for bailing me out of this condition. As a result of surfing through the world-wide-web and meeting tricks which are not helpful, I assumed my life was well over. Living devoid of the approaches to the difficulties you have sorted out by means of your good report is a critical case, as well as the kind which may have adversely damaged my career if I had not discovered the website. Your own ability and kindness in taking care of a lot of things was tremendous. I don't know what I would've done if I had not discovered such a thing like this. I can also at this point look ahead to my future. Thanks so much for this reliable and sensible guide. I won't be reluctant to refer your web page to anybody who requires support about this area.

hermes birkin

Thanks so much for giving everyone an exceptionally breathtaking possiblity to read from here. It is always so nice and stuffed with fun for me personally and my office friends to visit your web site more than 3 times in one week to see the latest guides you will have. Of course, I am just usually impressed with the extraordinary inspiring ideas served by you. Selected 3 ideas in this article are undoubtedly the very best we have all ever had.

Add new comment | arxic Drupal

Howdy I am so delighted I found your site, I
really found you by accident, while I was searching on Google for something else,
Nonetheless I am here now and would just like
to say thanks for a incredible post and a all round entertaining blog
(I also love the theme/design), I don’t have time to look over it all at the minute but I have
book-marked it and also added your RSS feeds, so when I have time I will be back to read a
great deal more, Please do keep up the awesome work.

yeezys

I want to show my love for your kind-heartedness giving support to visitors who should have guidance on this one content. Your special dedication to getting the message throughout had become really effective and has continually helped individuals much like me to get to their dreams. The insightful advice denotes this much a person like me and additionally to my mates. Best wishes; from everyone of us.

nike kd 12

Thank you a lot for providing individuals with remarkably brilliant possiblity to discover important secrets from this web site. It is often so great and stuffed with fun for me personally and my office colleagues to visit your site on the least 3 times per week to see the fresh items you have got. Not to mention, I'm usually astounded with your magnificent points served by you. Some 2 facts in this article are basically the very best I've ever had.

birkin bag

I happen to be writing to let you know what a remarkable encounter my cousin's child obtained browsing yuor web blog. She learned a wide variety of pieces, most notably what it's like to possess a marvelous giving mindset to make the rest without hassle comprehend specific extremely tough subject matter. You really did more than her expectations. Thank you for displaying the practical, trusted, edifying as well as fun tips on this topic to Janet.

Add new comment | arxic Drupal

Aw, this was an exceptionally good post. Taking the time and actual effort to generate a good
article… but what can I say… I put things off a lot and never manage to get
nearly anything done.

supreme clothing

I together with my guys happened to be viewing the excellent points found on your web page and all of a sudden I had an awful suspicion I never thanked the web site owner for those secrets. These ladies came consequently stimulated to read through all of them and now have in reality been taking pleasure in these things. Appreciation for being very considerate and for deciding on some useful subject areas most people are really desperate to know about. Our own sincere apologies for not saying thanks to sooner.

balenciaga shoes

I really wanted to jot down a simple remark to express gratitude to you for these marvelous tricks you are giving out here. My time-consuming internet look up has now been honored with useful tips to share with my colleagues. I would mention that we visitors actually are unequivocally lucky to live in a remarkable website with very many perfect professionals with good things. I feel extremely privileged to have seen your webpage and look forward to really more cool times reading here. Thanks a lot once more for a lot of things.

Add new comment | arxic Drupal

This design is steller! You most certainly know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to
start my own blog (well, almost...HaHa!) Excellent job.
I really enjoyed what you had to say, and more than that, how you presented it.
Too cool!

kate spade handbags

I wish to show some thanks to you just for rescuing me from such a difficulty. Right after browsing through the internet and coming across recommendations which are not pleasant, I figured my entire life was done. Living without the presence of approaches to the problems you've resolved by means of your main article content is a serious case, and those which might have in a wrong way damaged my entire career if I had not encountered your blog. The knowledge and kindness in touching all areas was precious. I am not sure what I would have done if I had not encountered such a solution like this. I can at this moment look forward to my future. Thanks very much for this impressive and results-oriented help. I will not be reluctant to recommend the website to anybody who requires guide on this topic.

vans outlet

I precisely had to appreciate you again. I'm not certain the things I would have implemented in the absence of the actual recommendations discussed by you over such industry. Certainly was the troublesome problem for me, nevertheless being able to see a new professional form you solved that took me to weep over happiness. I'm just happier for the information and then pray you comprehend what an amazing job you have been accomplishing training other individuals thru your blog post. More than likely you have never got to know all of us.

Add new comment | arxic Drupal

I know this web site presents quality depending content
and extra data, is there any other web page which offers
these kinds of information in quality?

zx flux

I would like to show thanks to the writer just for rescuing me from this instance. As a result of exploring throughout the world wide web and seeing concepts which are not powerful, I figured my entire life was done. Being alive without the approaches to the difficulties you have fixed by means of this post is a critical case, as well as ones which may have in a negative way damaged my entire career if I had not noticed your site. Your main know-how and kindness in touching all the things was priceless. I am not sure what I would've done if I had not come upon such a solution like this. I can also now relish my future. Thank you very much for this expert and effective guide. I will not think twice to suggest the sites to any person who would like guidelines about this subject.

yeezy

I am also writing to make you understand what a great experience my cousin's girl gained using yuor web blog. She even learned several things, which included how it is like to possess an excellent helping mindset to have other individuals easily fully grasp certain tortuous topics. You actually exceeded our own expected results. I appreciate you for displaying such precious, healthy, educational as well as easy tips about your topic to Evelyn.

Add new comment | arxic Drupal

Every weekend i used to pay a quick visit this web page, for the reason that i want enjoyment,
as this this website conations really good funny data too.

golden goose outlet

I would like to show thanks to this writer for bailing me out of this particular matter. As a result of checking throughout the the web and meeting basics which were not pleasant, I figured my entire life was well over. Existing devoid of the strategies to the problems you've resolved by way of your report is a critical case, and the ones that might have in a negative way affected my career if I had not encountered your web site. Your primary understanding and kindness in controlling all things was important. I don't know what I would've done if I had not come upon such a stuff like this. I can also now look forward to my future. Thank you very much for this impressive and sensible help. I will not think twice to propose the website to anybody who would need direction about this subject.

Add new comment | arxic Drupal

Hello, There's no doubt that your blog could possibly be having web browser
compatibility issues. Whenever I look at your blog in Safari, it looks fine
however, if opening in Internet Explorer, it has some overlapping issues.
I merely wanted to provide you with a quick heads up!
Besides that, excellent blog!

fila

I precisely wished to say thanks all over again. I'm not certain the things that I could possibly have used in the absence of the type of hints shared by you on my topic. Completely was a real challenging dilemma in my position, however , looking at this skilled mode you treated that made me to cry with happiness. I am happy for your information and thus hope that you are aware of a powerful job you are putting in educating some other people through your websites. More than likely you haven't met any of us.

Add new comment | arxic Drupal

I used to be recommended this web site through my cousin. I
am no longer sure whether or not this post is written by means of him as nobody
else recognize such unique about my trouble. You're amazing!
Thanks!

fila shoes

I just wanted to make a quick note to be able to appreciate you for the pleasant ideas you are placing on this website. My time-consuming internet lookup has now been honored with pleasant knowledge to talk about with my friends and family. I 'd tell you that most of us website visitors are truly blessed to dwell in a useful network with very many lovely individuals with beneficial secrets. I feel truly grateful to have used the weblog and look forward to plenty of more exciting minutes reading here. Thank you once again for a lot of things.

hermes bags

I am commenting to make you understand of the outstanding discovery our daughter found going through your site. She mastered a lot of pieces, most notably what it's like to have an awesome coaching spirit to get many others smoothly completely grasp chosen tricky matters. You really did more than our own expectations. Thank you for supplying the invaluable, dependable, informative and cool guidance on that topic to Tanya.

balenciaga

I would like to express appreciation to this writer for rescuing me from this particular trouble. After browsing throughout the internet and obtaining ways which were not pleasant, I figured my life was over. Existing minus the approaches to the issues you've fixed through the website is a serious case, and those that could have in a negative way damaged my career if I had not noticed the website. Your personal competence and kindness in touching every item was helpful. I'm not sure what I would've done if I had not come upon such a subject like this. It's possible to now relish my future. Thanks for your time so much for the expert and result oriented guide. I will not hesitate to recommend your blog post to any individual who needs to have direction about this matter.

goyard wallet

I am glad for commenting to make you be aware of what a fine experience my wife's daughter enjoyed going through the blog. She noticed such a lot of issues, most notably how it is like to have an awesome helping mood to let others just fully understand specified tricky issues. You actually exceeded my expected results. Thanks for delivering these good, safe, explanatory and in addition fun guidance on this topic to Lizeth.

off white clothing

I have to voice my respect for your kindness supporting men who must have guidance on this particular subject matter. Your personal dedication to getting the solution throughout came to be especially informative and has surely empowered individuals much like me to attain their endeavors. Your entire invaluable help and advice means a great deal to me and extremely more to my office colleagues. Best wishes; from everyone of us.

adidas yeezy

I am just writing to let you understand of the perfect experience my friend's girl encountered studying yuor web blog. She figured out a good number of pieces, including what it is like to have a very effective helping spirit to make the mediocre ones just learn specific complicated matters. You actually surpassed visitors' desires. Many thanks for imparting these useful, trusted, edifying and unique thoughts on that topic to Tanya.

yeezy shoes

I precisely wanted to appreciate you once more. I'm not certain the things I might have tried without these opinions documented by you directly on such a area of interest. It became a very fearsome crisis for me, but finding out the very specialized mode you solved that made me to jump with fulfillment. I am thankful for the support and expect you really know what a great job your are doing teaching others by way of your webpage. Most probably you've never encountered any of us.

nike foamposite

I precisely needed to appreciate you once more. I'm not certain what I would have created without the information contributed by you concerning my concern. It had been a troublesome scenario in my circumstances, however , being able to view this specialized avenue you dealt with the issue made me to leap for joy. Now i am thankful for this service as well as wish you comprehend what a powerful job you are always carrying out instructing others via your blog. Most likely you have never come across any of us.

curry 5

I want to show appreciation to you for rescuing me from this particular circumstance. Just after searching throughout the online world and getting principles that were not productive, I figured my entire life was over. Living minus the solutions to the problems you've resolved through your main posting is a crucial case, as well as the ones which could have in a negative way damaged my career if I hadn't discovered your website. Your own understanding and kindness in handling a lot of things was invaluable. I am not sure what I would have done if I hadn't come across such a solution like this. I'm able to now relish my future. Thanks a lot so much for the impressive and effective help. I won't hesitate to refer your web blog to anyone who wants and needs assistance about this situation.

birkin bag

I wish to show my respect for your generosity giving support to those individuals that must have help on this one field. Your real commitment to getting the message all through had been exceptionally informative and have regularly enabled men and women much like me to arrive at their pursuits. The useful help and advice denotes a lot a person like me and far more to my fellow workers. Best wishes; from everyone of us.

Pages

Add new comment