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

vans outlet

Aw, this was a very nice post. In idea I wish to put in writing like this moreover ?taking time and precise effort to make an excellent article?however what can I say?I procrastinate alot and by no means seem to get something done.

off white clothing

Needed to create you this little bit of observation to help thank you so much over again relating to the pleasing information you've shared in this article. It is wonderfully open-handed with you to convey extensively what many people could have sold as an electronic book in making some money for their own end, certainly seeing that you could possibly have done it in case you desired. These tricks likewise acted to become a easy way to know that other individuals have the same interest much like mine to know good deal more related to this problem. I am certain there are lots of more pleasant instances up front for people who read your website.

air max 90

I precisely had to say thanks all over again. I'm not certain the things that I would have undertaken without the creative concepts shared by you directly on that area of interest. Entirely was the frightful setting for me personally, nevertheless taking a look at a skilled way you dealt with the issue made me to cry with fulfillment. I'm thankful for the help and then sincerely hope you find out what a powerful job you're getting into educating most people with the aid of a site. More than likely you have never met all of us.

jordan 4

I would like to convey my passion for your generosity for visitors who must have help on in this field. Your real commitment to getting the message all over turned out to be wonderfully good and has usually empowered workers like me to achieve their pursuits. The informative useful information denotes a whole lot to me and additionally to my office workers. Best wishes; from each one of us.

convese outlet

Thank you a lot for providing individuals with such a marvellous chance to check tips from here. It can be so kind and as well , packed with fun for me and my office fellow workers to visit your blog not less than 3 times in a week to read the newest guidance you will have. And lastly, I'm certainly impressed with all the sensational advice you give. Some 1 ideas in this posting are surely the most suitable I've had.

nike air max 2017

Thank you a lot for giving everyone an extremely terrific chance to read from this web site. It is often so lovely and also stuffed with amusement for me and my office friends to visit your web site on the least thrice per week to read through the latest secrets you have. And lastly, I am just actually happy with your attractive tricks served by you. Some 2 ideas in this article are definitely the most efficient we've ever had.

moncler

I would like to show appreciation to the writer for rescuing me from this type of difficulty. Because of scouting through the internet and getting principles which were not pleasant, I believed my entire life was gone. Living without the presence of solutions to the issues you've fixed all through your entire article is a crucial case, as well as the kind which might have adversely damaged my career if I hadn't discovered your blog post. Your own personal competence and kindness in touching all the stuff was invaluable. I'm not sure what I would've done if I had not encountered such a subject like this. I can at this point look forward to my future. Thanks very much for your high quality and amazing guide. I will not think twice to refer your web page to anyone who ought to have support about this topic.

lebron 16

I wanted to put you this little observation in order to say thanks a lot yet again regarding the spectacular advice you've shown here. It was wonderfully generous of you to provide freely just what a number of us would've made available as an e book in order to make some dough on their own, specifically seeing that you might well have tried it in the event you desired. Those secrets also acted to become a fantastic way to realize that other people have the same fervor just like my own to figure out a great deal more pertaining to this condition. I am sure there are millions of more pleasurable times up front for many who read carefully your site.

russell westbrook shoes

I not to mention my friends appeared to be looking through the excellent tips and tricks on your website and then all of the sudden got a terrible feeling I had not thanked the web site owner for them. All the people ended up as a result warmed to study all of them and now have honestly been tapping into them. Appreciation for being well thoughtful and for opting for this sort of amazing tips millions of individuals are really needing to learn about. My very own honest regret for not expressing appreciation to you earlier.

jordan shoes

I and my pals were digesting the excellent guides located on your web site and quickly I had a horrible feeling I never thanked the web blog owner for those secrets. Those guys were totally very interested to read all of them and now have pretty much been enjoying them. Appreciation for simply being considerably helpful as well as for considering this sort of high-quality guides most people are really needing to know about. My personal honest apologies for not expressing gratitude to sooner.

jordan shoes

I have to show my thanks to the writer just for bailing me out of this particular matter. After looking out through the search engines and seeing opinions which were not productive, I believed my life was gone. Being alive without the presence of approaches to the problems you have fixed through this blog post is a critical case, and the kind that might have in a wrong way damaged my entire career if I hadn't discovered the blog. Your actual talents and kindness in taking care of all areas was important. I'm not sure what I would've done if I had not discovered such a stuff like this. I can also now look ahead to my future. Thank you so much for the expert and results-oriented help. I won't hesitate to refer your web page to any person who needs to have support on this topic.

supreme t shirt

I precisely wished to thank you very much once again. I'm not certain the things that I could possibly have carried out without these smart ideas shared by you concerning such a subject. It absolutely was a real troublesome issue in my opinion, but taking note of this specialised mode you treated the issue forced me to jump for delight. Now i am happier for the assistance and hope that you are aware of a great job you were providing educating the others via your web page. I'm certain you have never got to know any of us.

kd 11

I really wanted to jot down a note to be able to express gratitude to you for some of the marvelous techniques you are posting on this website. My time-consuming internet look up has at the end of the day been paid with brilliant ideas to go over with my close friends. I would assert that many of us site visitors are truly fortunate to dwell in a notable community with so many lovely individuals with useful basics. I feel really grateful to have encountered your entire web pages and look forward to really more enjoyable times reading here. Thanks a lot once more for all the details.

nike vapormax

I precisely desired to thank you very much once more. I am not sure what I would have accomplished in the absence of the aspects provided by you on such concern. It was before an absolute fearsome concern in my opinion, but coming across the very skilled strategy you handled the issue took me to cry over fulfillment. I'm grateful for the service as well as wish you know what a powerful job you're undertaking teaching men and women through your site. More than likely you've never come across all of us.

coach outlet

I and my pals were reading the nice secrets and techniques on the blog and before long developed a terrible feeling I never expressed respect to the blog owner for those strategies. These women were consequently excited to see them and already have absolutely been using those things. I appreciate you for actually being quite accommodating as well as for considering such notable guides most people are really desirous to learn about. Our own sincere apologies for not saying thanks to you earlier.

golden goose

Thank you a lot for providing individuals with an exceptionally pleasant opportunity to read in detail from this blog. It is always very terrific and also stuffed with a good time for me and my office friends to search your site at minimum three times in one week to learn the latest secrets you will have. Not to mention, I am actually fulfilled concerning the attractive principles you give. Selected 3 facts on this page are easily the most effective I have had.

nike huarache

I am glad for writing to make you understand what a brilliant discovery my wife's daughter had visiting your blog. She discovered such a lot of things, not to mention what it is like to have a wonderful helping style to make others really easily know just exactly selected complicated things. You actually exceeded people's expected results. Thanks for churning out such useful, dependable, explanatory and fun tips on this topic to Ethel.

birkin bag

My wife and i ended up being so glad that Emmanuel managed to carry out his reports using the precious recommendations he was given from your site. It is now and again perplexing to simply be giving for free information and facts which usually many people might have been selling. And now we discover we now have you to give thanks to for that. The main explanations you made, the simple site menu, the friendships your site help to instill - it's got most wonderful, and it's really facilitating our son in addition to us reckon that that topic is thrilling, and that is extremely indispensable. Thanks for everything!

golden goose

I would like to express some appreciation to you just for rescuing me from such a circumstance. As a result of looking out through the online world and seeing recommendations that were not beneficial, I believed my life was over. Existing without the strategies to the issues you've sorted out by means of the post is a crucial case, and the ones which may have badly affected my career if I hadn't encountered the website. That talents and kindness in touching a lot of stuff was useful. I'm not sure what I would have done if I hadn't come upon such a solution like this. I'm able to at this moment look forward to my future. Thank you very much for the expert and result oriented help. I won't hesitate to refer your site to any individual who should receive direction on this subject matter.

air max 95

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

vapormax

I am typically to running a blog and i actually appreciate your content. The article has really peaks my interest. I am going to bookmark your site and hold checking for brand new information.

cheap jordans

Spot on with this write-up, I actually think this website wants rather more consideration. I抣l most likely be once more to learn rather more, thanks for that info.

air max 270

You must participate in a contest for among the finest blogs on the web. I will recommend this web site!

nike off whtie

I'm typically to running a blog and i actually respect your content. The article has actually peaks my interest. I am going to bookmark your website and maintain checking for brand spanking new information.

cheap jordans

There are actually a variety of details like that to take into consideration. That could be a nice level to deliver up. I provide the thoughts above as basic inspiration however clearly there are questions just like the one you bring up the place an important thing can be working in trustworthy good faith. I don?t know if finest practices have emerged round things like that, but I'm positive that your job is clearly recognized as a good game. Each boys and girls feel the impact of just a second抯 pleasure, for the rest of their lives.

hermes belts for men

I needed to draft you one very little observation to be able to give thanks the moment again regarding the extraordinary information you have provided on this site. This has been incredibly generous of you to give without restraint all that most people might have made available for an electronic book to help make some profit on their own, chiefly seeing that you might have tried it in case you desired. These tips in addition served as the good way to fully grasp most people have a similar zeal the same as my own to see way more concerning this condition. I am sure there are several more enjoyable situations in the future for many who read your site.

converse outlet store

I simply wished to appreciate you all over again. I do not know the things that I would've carried out without these tricks contributed by you concerning such theme. It had become a real scary problem for me, but considering a skilled manner you managed it made me to leap for gladness. I will be happy for this work and then hope you really know what a great job that you're providing educating other individuals using a site. More than likely you have never come across any of us.

zx flux

I and my friends came examining the good guides found on your web blog then then came up with a horrible feeling I never thanked you for those techniques. All of the young boys happened to be absolutely very interested to read through them and have now in truth been taking advantage of them. Thank you for really being considerably considerate and then for finding such quality things millions of individuals are really needing to be informed on. Our honest apologies for not saying thanks to you earlier.

nike air max 90

I'm commenting to let you know what a incredible discovery my friend's daughter encountered browsing your web site. She came to understand many things, which included how it is like to possess an excellent helping mood to have the rest with no trouble learn specific impossible topics. You undoubtedly surpassed people's desires. Thank you for delivering the effective, safe, edifying not to mention easy tips on this topic to Ethel.

yeezy

I must get across my admiration for your kindness giving support to all those that must have guidance on this situation. Your special commitment to passing the message all-around became amazingly beneficial and have really permitted guys and women like me to reach their goals. This informative guide means much to me and additionally to my colleagues. Thanks a ton; from each one of us.

nike outlet

Thanks for each of your work on this website. Kate enjoys engaging in research and it is easy to understand why. Many of us learn all of the dynamic manner you produce valuable ideas by means of this website and in addition improve contribution from website visitors on this point plus our daughter is without question learning a great deal. Take advantage of the remaining portion of the new year. You are always performing a glorious job.

supreme

I needed to create you the little observation to be able to thank you the moment again just for the great pointers you have shared in this case. It has been strangely generous with people like you to make extensively all that a lot of folks could have advertised for an e-book to generate some profit for their own end, even more so since you might well have tried it in case you decided. These concepts likewise worked as a easy way to be sure that most people have similar passion just like mine to figure out good deal more when it comes to this matter. I am certain there are a lot more pleasurable situations ahead for those who browse through your blog post.

hermes belts

I simply needed to thank you very much all over again. I am not sure the things I could possibly have gone through in the absence of the actual ideas discussed by you over that concern. This was a real daunting matter for me personally, but noticing a new specialised fashion you processed the issue forced me to weep over fulfillment. I will be grateful for this guidance and even have high hopes you comprehend what a great job you happen to be doing training many people through your blog. Probably you've never encountered all of us.

vapormax

Thank you a lot for giving everyone an exceptionally brilliant chance to read critical reviews from this website. It is often so awesome and full of a great time for me personally and my office acquaintances to visit your site minimum thrice every week to study the fresh secrets you have got. And of course, I'm so actually amazed considering the spectacular thoughts you serve. Selected 3 tips in this article are honestly the simplest we have had.

goyard

I simply needed to appreciate you all over again. I'm not certain the things that I might have tried in the absence of these solutions shown by you on this theme. Completely was a hard matter in my view, but encountering your specialised strategy you handled that made me to cry for delight. Now i'm happier for your support and hope that you really know what an amazing job you have been carrying out teaching men and women using your site. Most likely you've never met all of us.

golden goose sneakers

I have to show my appreciation to this writer just for bailing me out of such a instance. After browsing throughout the internet and seeing techniques that were not beneficial, I thought my entire life was done. Being alive without the presence of strategies to the difficulties you have resolved by way of your main posting is a serious case, as well as the ones which may have in a wrong way damaged my entire career if I had not noticed your web site. Your primary mastery and kindness in dealing with every item was tremendous. I'm not sure what I would have done if I hadn't discovered such a thing like this. It's possible to at this time relish my future. Thanks for your time very much for your high quality and results-oriented help. I won't hesitate to suggest your web blog to any individual who will need guidelines about this matter.

nike basketball shoes

I intended to create you the very little remark to finally say thank you once again about the unique tactics you have shared above. It was tremendously generous with people like you to provide easily all that numerous people would have marketed as an e book to earn some cash on their own, chiefly considering that you might have tried it if you decided. Those principles also served to be the fantastic way to know that other individuals have a similar desire just as my own to find out a whole lot more pertaining to this problem. I am certain there are several more pleasurable opportunities in the future for people who discover your blog.

jordan 4

I needed to put you that very little note in order to say thanks once again for the extraordinary knowledge you've featured at this time. It is so seriously open-handed of you to give extensively what exactly a number of people would've made available for an e book in making some dough for their own end, specifically considering the fact that you could have tried it in case you decided. The guidelines in addition served like a great way to fully grasp that other people have the identical keenness really like my personal own to figure out somewhat more with regards to this condition. I'm sure there are numerous more pleasant situations in the future for individuals that check out your website.

jordan shoes

I am commenting to make you be aware of what a brilliant encounter our child went through studying the blog. She realized such a lot of issues, with the inclusion of how it is like to have an amazing helping spirit to get the mediocre ones with ease gain knowledge of selected very confusing subject areas. You really did more than visitors' expected results. Thank you for presenting those essential, healthy, informative and as well as fun tips on the topic to Jane.

hermes bag

I together with my buddies have been checking the excellent solutions from your website and so before long developed a horrible suspicion I never thanked the web blog owner for those strategies. The men are already so joyful to learn all of them and have in effect sincerely been taking advantage of those things. Thanks for turning out to be really thoughtful and also for utilizing these kinds of superior subject matter millions of individuals are really desperate to be aware of. Our own sincere apologies for not expressing gratitude to earlier.

golden goose sneakers

I wish to convey my love for your kindness for all those that should have assistance with this important content. Your special dedication to getting the solution all through turned out to be unbelievably interesting and has allowed professionals like me to reach their goals. Your own insightful useful information denotes so much to me and substantially more to my fellow workers. Many thanks; from all of us.

michael kors handbags

I just wanted to construct a quick remark to appreciate you for these lovely points you are giving out on this site. My rather long internet search has at the end of the day been paid with excellent insight to share with my contacts. I 'd state that that we visitors actually are unequivocally fortunate to dwell in a really good community with many special individuals with great tips and hints. I feel very much grateful to have come across the site and look forward to so many more cool times reading here. Thanks a lot once more for a lot of things.

ferragamo sale

I together with my buddies have already been looking at the great helpful hints on your web page and then instantly got a terrible suspicion I never thanked the site owner for those secrets. My men are actually totally very interested to learn them and have in effect clearly been using these things. Thank you for simply being really considerate and also for opting for some terrific subjects millions of individuals are really wanting to be informed on. Our sincere apologies for not expressing gratitude to sooner.

supreme shirt

A lot of thanks for all of the hard work on this website. My daughter really loves carrying out internet research and it's really simple to grasp why. My spouse and i learn all of the dynamic tactic you make precious techniques on your web blog and even invigorate participation from people on this point plus our own child is understanding a lot of things. Take pleasure in the rest of the year. You have been carrying out a dazzling job.

fitflop sale

Spot on with this write-up, I really assume this website needs much more consideration. I抣l most likely be again to learn way more, thanks for that info.

Pages

Add new comment