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

Simply wish to say your article is as astonishing.
The clearness for your put up is simply nice and i could suppose you're knowledgeable on this subject.

Fine with your permission let me to clutch your feed to keep
updated with coming near near post. Thanks one million and please carry on the enjoyable work.

coach outlet store online

I intended to write you a tiny observation to be able to thank you so much again for all the superb methods you have discussed here. It has been really open-handed with you to make extensively just what a few individuals could possibly have made available as an electronic book in making some dough for their own end, and in particular since you might have done it if you ever considered necessary. Those creative ideas additionally acted to become a great way to be certain that the rest have similar zeal just like my personal own to find out good deal more on the subject of this issue. I know there are millions of more pleasant sessions up front for folks who view your blog.

yeezy boost 350

I want to express my thanks to this writer just for rescuing me from this particular trouble. As a result of surfing throughout the the net and seeing concepts which were not helpful, I assumed my entire life was done. Being alive minus the strategies to the issues you've sorted out all through your main short article is a crucial case, as well as ones that could have adversely damaged my career if I had not noticed your blog post. Your skills and kindness in handling every aspect was crucial. I am not sure what I would have done if I had not come upon such a stuff like this. I can also at this moment look forward to my future. Thanks for your time so much for this skilled and sensible guide. I will not think twice to endorse your web page to anyone who would like care on this matter.

golden goose

I and also my pals were actually checking the good helpful hints from the blog and so before long developed a terrible feeling I never expressed respect to the site owner for those techniques. Those ladies were definitely excited to read all of them and already have clearly been making the most of them. Thanks for indeed being really considerate and then for getting this kind of great useful guides most people are really desperate to be informed on. My personal sincere apologies for not expressing gratitude to you sooner.

nike air force

I would like to point out my affection for your kindness in support of folks who require help with in this area. Your special dedication to getting the solution around ended up being really practical and have continually empowered guys like me to achieve their targets. Your own important instruction means a great deal a person like me and substantially more to my office workers. Thanks a ton; from each one of us.

nike air max 270

I happen to be commenting to let you be aware of of the wonderful experience my friend's girl gained going through your blog. She came to find some things, which include what it is like to possess a great coaching mood to make men and women really easily grasp a number of extremely tough subject areas. You actually exceeded visitors' desires. Many thanks for offering these priceless, trustworthy, educational not to mention fun thoughts on the topic to Jane.

supreme outlet

I and my guys came viewing the best points on your web page and all of a sudden I had a horrible suspicion I had not thanked the web blog owner for them. All of the young boys were definitely so thrilled to study them and now have very much been taking advantage of them. Appreciate your getting so accommodating and then for figuring out this sort of fabulous topics most people are really eager to understand about. Our honest regret for not expressing appreciation to you earlier.

nike react

I truly wanted to type a remark so as to express gratitude to you for all of the superb tips and hints you are giving on this site. My extensive internet search has now been paid with brilliant points to go over with my neighbours. I would say that many of us visitors are quite fortunate to live in a great network with very many awesome professionals with good methods. I feel very privileged to have used the web page and look forward to many more thrilling moments reading here. Thanks once more for all the details.

jordan shoes

I wanted to draft you one little remark just to thank you so much as before for your gorgeous ideas you've shown in this case. It has been so particularly open-handed with people like you to deliver openly what exactly many individuals could have offered for sale as an e book to help make some profit on their own, even more so now that you might have tried it if you ever wanted. Those creative ideas as well worked to be a easy way to realize that other people online have the same eagerness similar to my personal own to understand more and more with regards to this problem. I am sure there are lots of more enjoyable sessions up front for those who discover your website.

ralph lauren sale

I precisely wanted to appreciate you all over again. I do not know the things that I would've implemented in the absence of those secrets shown by you relating to that concern. Entirely was a very traumatic case in my circumstances, nevertheless witnessing a new specialized avenue you solved it took me to weep over delight. I'm grateful for the work and trust you find out what a great job that you are doing training many others through your webpage. More than likely you haven't come across all of us.

yeezy shoes

I am also commenting to let you be aware of what a wonderful experience my wife's child found viewing your site. She mastered plenty of details, which included what it's like to possess a marvelous helping nature to let a number of people really easily know precisely several impossible subject matter. You really did more than readers' expectations. Thank you for giving those warm and friendly, healthy, revealing not to mention easy thoughts on your topic to Emily.

adidas yeezy

Thanks so much for providing individuals with remarkably superb chance to read from this web site. It is always so great and also packed with a great time for me and my office colleagues to search the blog at the very least three times in 7 days to see the latest issues you have. And lastly, I'm just usually contented with all the perfect tricks you serve. Certain 2 facts on this page are undeniably the most effective we have had.

curry 6

A lot of thanks for all of your labor on this website. My mother loves making time for internet research and it's easy to understand why. Almost all hear all concerning the powerful form you make informative guidance by means of this web blog and as well as foster participation from other people on the situation so our girl has been becoming educated so much. Enjoy the rest of the year. You are doing a pretty cool job.

canada goose jacket

A lot of thanks for each of your labor on this web site. Gloria takes pleasure in carrying out research and it's really easy to understand why. Most of us hear all relating to the powerful way you make both useful and interesting things through the blog and welcome participation from people about this concept and our own simple princess is being taught so much. Take advantage of the rest of the new year. You are carrying out a stunning job.

cheap jordans

I must express my gratitude for your kindness for those who need help with that concept. Your real dedication to getting the solution throughout ended up being quite beneficial and have constantly allowed some individuals just like me to realize their desired goals. The warm and helpful help and advice can mean this much a person like me and especially to my fellow workers. Best wishes; from everyone of us.

chrome hearts outlet

I am glad for writing to let you know of the fantastic experience my friend's girl obtained reading through your site. She picked up a wide variety of details, which include how it is like to have an excellent coaching nature to get other folks with ease fully grasp a number of problematic subject matter. You actually surpassed her expected results. I appreciate you for distributing the powerful, trustworthy, revealing and even fun tips about this topic to Kate.

nike basketball shoes

Thank you so much for providing individuals with an extraordinarily remarkable chance to read critical reviews from this site. It is always so amazing and as well , full of a lot of fun for me and my office mates to visit your blog minimum three times weekly to read through the newest secrets you will have. Of course, I'm also certainly satisfied concerning the very good principles served by you. Some 4 facts on this page are essentially the very best I have had.

fila

Good post. I study one thing more difficult on completely different blogs everyday. It's going to all the time be stimulating to read content material from different writers and apply a bit something from their store. I抎 favor to use some with the content on my weblog whether you don抰 mind. Natually I抣l give you a link in your web blog. Thanks for sharing.

yeezy boost 350

I have to show some thanks to you just for rescuing me from this particular challenge. Because of exploring throughout the world wide web and meeting tips which are not powerful, I assumed my entire life was gone. Being alive devoid of the answers to the problems you've sorted out as a result of your main article content is a serious case, as well as those which could have in a negative way affected my entire career if I hadn't discovered your website. Your primary skills and kindness in playing with all the things was tremendous. I don't know what I would've done if I hadn't come upon such a step like this. I can also now relish my future. Thank you very much for your professional and amazing guide. I won't be reluctant to endorse the sites to any person who needs and wants support about this subject.

moncler outlet

I have to get across my respect for your kindness for folks that require help with that subject. Your very own dedication to passing the solution all through had been rather advantageous and have all the time encouraged ladies just like me to get to their dreams. Your own valuable tips and hints denotes this much to me and substantially more to my peers. Thanks a lot; from each one of us.

Add new comment | arxic Drupal

Hi, I do believe this is a great site. I stumbledupon it ;) I will come back yet again since i have bookmarked it.
Money and freedom is the best way to change, may you be rich and continue to guide other people.

yeezy boost 350

I would like to express some thanks to this writer for bailing me out of this type of issue. Because of surfing throughout the world-wide-web and getting things which were not pleasant, I assumed my life was done. Living without the presence of strategies to the difficulties you've resolved by way of your entire posting is a critical case, and ones that would have in a negative way damaged my entire career if I had not noticed your web site. That capability and kindness in taking care of almost everything was precious. I am not sure what I would've done if I had not discovered such a solution like this. I'm able to at this moment relish my future. Thanks very much for your reliable and sensible guide. I will not think twice to suggest the website to anyone who would like assistance on this subject matter.

curry shoes

I would like to get across my respect for your kind-heartedness supporting persons that need help with this subject. Your real commitment to getting the message throughout appeared to be rather important and have continually enabled others much like me to realize their ambitions. Your new warm and helpful guideline signifies a great deal to me and somewhat more to my office workers. With thanks; from everyone of us.

Kanye West shoes

I needed to draft you one tiny word so as to say thanks again relating to the pleasant principles you've documented at this time. This is so wonderfully generous with you in giving unhampered all that many of us would have made available for an electronic book to make some bucks for themselves, particularly considering that you might well have done it if you decided. These tactics as well worked to become easy way to comprehend someone else have the same eagerness the same as my own to figure out more and more when it comes to this problem. I believe there are some more fun periods up front for folks who read your site.

retro jordans

I wanted to compose you the very small word to help thank you so much again for your personal awesome tricks you have provided on this website. It was certainly unbelievably generous with people like you to deliver unreservedly all that most people would have advertised for an e-book in making some cash for their own end, precisely now that you could have done it in case you considered necessary. Those basics also acted to become a easy way to be aware that other people have the same interest the same as my personal own to find out more and more concerning this matter. I think there are lots of more pleasant sessions ahead for people who examine your site.

ferragamo sale

Thank you a lot for giving everyone an exceptionally remarkable opportunity to check tips from this site. It can be so superb and as well , full of a great time for me and my office friends to visit your web site at the very least thrice weekly to read through the new issues you have. And definitely, I'm just actually contented with all the amazing ideas you serve. Some 3 points in this article are definitely the most efficient I have had.

supreme hoodie

I would like to express my appreciation to the writer just for rescuing me from this particular circumstance. Because of browsing throughout the world-wide-web and coming across ways which are not powerful, I assumed my entire life was over. Existing without the strategies to the problems you've sorted out all through your main blog post is a critical case, as well as the kind which could have negatively damaged my career if I had not discovered your blog post. Your good expertise and kindness in touching all things was important. I am not sure what I would have done if I hadn't discovered such a point like this. I can at this point look forward to my future. Thank you very much for the expert and sensible help. I will not be reluctant to endorse your web blog to anybody who should get care on this problem.

goyard bags

I intended to draft you the little word to be able to thank you very much over again for all the pleasant thoughts you've shared in this article. This has been quite incredibly open-handed of people like you to supply unreservedly what exactly many people would have distributed for an e book in order to make some profit for themselves, mostly since you could have tried it in case you wanted. These good ideas also served to provide a good way to fully grasp that other individuals have the identical fervor just as mine to understand many more with respect to this issue. Certainly there are several more pleasurable periods up front for individuals who see your website.

ferragamo sale

Thank you a lot for providing individuals with remarkably splendid chance to check tips from this web site. It is often very superb plus full of a lot of fun for me and my office mates to visit your website no less than thrice weekly to see the fresh tips you will have. And of course, I am just at all times pleased with all the extraordinary tricks you serve. Certain 2 points on this page are rather the finest I've ever had.

balenciaga trainers

I not to mention my buddies have already been checking the good tips located on your website and suddenly got an awful suspicion I never expressed respect to the web blog owner for those techniques. The men ended up as a result glad to read all of them and now have without a doubt been taking pleasure in them. Thanks for simply being considerably helpful and then for settling on some outstanding subject areas most people are really desirous to understand about. My personal sincere regret for not expressing gratitude to you earlier.

converse

I happen to be writing to make you be aware of of the incredible encounter our girl encountered going through your web site. She mastered a wide variety of details, which include what it's like to have an excellent teaching mindset to make other individuals with no trouble completely grasp some multifaceted subject matter. You actually surpassed our own desires. Thank you for displaying the practical, safe, revealing as well as unique guidance on this topic to Emily.

jordan shoes

My spouse and i got now ecstatic Chris managed to conclude his analysis through your ideas he discovered using your weblog. It's not at all simplistic to just always be giving for free secrets and techniques that men and women may have been selling. We already know we've got the writer to be grateful to because of that. The type of explanations you have made, the easy web site navigation, the friendships you aid to create - it is everything wonderful, and it's really facilitating our son and our family believe that the article is satisfying, which is certainly really essential. Thanks for all the pieces!

curry 4 shoes

Thank you so much for giving everyone an exceptionally pleasant possiblity to discover important secrets from this site. It is usually very beneficial and stuffed with a lot of fun for me and my office mates to search the blog nearly thrice in a week to study the new stuff you have. And indeed, I am always happy with all the breathtaking information you serve. Some 4 facts in this posting are in truth the most efficient we have all ever had.

supreme clothing

I intended to send you this very small remark so as to say thank you over again just for the splendid opinions you've contributed here. It is quite pretty open-handed of you giving unreservedly precisely what some people might have offered for sale as an ebook to help with making some dough for themselves, primarily considering the fact that you might have tried it if you desired. These tactics likewise acted like the good way to fully grasp that many people have the same fervor just like mine to figure out a whole lot more with regard to this problem. I'm certain there are a lot more fun sessions ahead for folks who scan through your blog.

nike shoes

Needed to write you the very little remark to thank you very much once again with the beautiful techniques you have featured in this article. This has been quite strangely open-handed with people like you to make extensively what exactly some people might have offered for an ebook to end up making some profit for their own end, specifically considering the fact that you might have tried it if you ever considered necessary. Those pointers also acted to be a fantastic way to know that the rest have similar interest much like my own to figure out a good deal more when it comes to this matter. I believe there are numerous more enjoyable opportunities up front for folks who looked at your blog post.

supreme clothing

Thanks so much for giving everyone a very nice possiblity to read articles and blog posts from this site. It's usually very superb and also full of a great time for me personally and my office friends to visit your blog really three times a week to learn the newest secrets you will have. And of course, I am just always happy with the incredible inspiring ideas you give. Some 3 tips in this posting are surely the most beneficial we have all had.

goyard

I wanted to send you that tiny note to finally thank you so much over again for those precious opinions you've contributed at this time. It's certainly shockingly open-handed of people like you to supply publicly all many individuals would have supplied as an e-book to earn some dough for themselves, and in particular seeing that you could have tried it in the event you decided. Those guidelines additionally worked like the easy way to know that other people have the same dreams really like my own to realize good deal more with reference to this problem. I am certain there are millions of more pleasurable instances in the future for those who looked over your blog.

curry 6

Good day! I simply want to give an enormous thumbs up for the great information you will have right here on this post. I can be coming back to your weblog for extra soon.

vapormax

I抎 should check with you here. Which isn't one thing I usually do! I enjoy reading a put up that may make individuals think. Additionally, thanks for permitting me to remark!

Add new comment | arxic Drupal

Hello there! I know this is kind of off topic but I was wondering if you knew where I could get a captcha plugin for
my comment form? I'm using the same blog platform
as yours and I'm having trouble finding one? Thanks a lot!

coach outlet store

Spot on with this write-up, I actually think this website needs far more consideration. I抣l in all probability be again to learn rather more, thanks for that info.

Add new comment | arxic Drupal

Your style is so unique compared to other people I've read stuff from.
Thank you for posting when you have the opportunity, Guess I will just bookmark this site.

longchamp handbags

Thanks a lot for providing individuals with remarkably terrific opportunity to read articles and blog posts from this website. It is usually very good and as well , full of amusement for me and my office friends to visit your website the equivalent of three times weekly to find out the newest items you have. And lastly, we're certainly satisfied concerning the powerful information you give. Selected two facts on this page are easily the finest we've ever had.

Add new comment | arxic Drupal

What's up everybody, here every person is sharing these kinds of familiarity, thus it's nice
to read this weblog, and I used to visit this weblog
all the time.

Add new comment | arxic Drupal

Today, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a
forty foot drop, just so she can be a youtube sensation. My iPad
is now broken and she has 83 views. I know this is entirely off topic but I had
to share it with someone!

yeezy boost 350

A lot of thanks for all of the work on this site. My mum really loves going through investigation and it is obvious why. Most people know all about the powerful manner you produce effective tips and hints on this blog and therefore increase participation from some others on this matter plus my daughter is without question studying so much. Take pleasure in the remaining portion of the year. You are always doing a really good job.

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.

Pages

Add new comment