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

Excellent items from you, man. I have have in mind your stuff previous to and you're just extremely wonderful.
I really like what you've got right here, really like what you're saying and the way by which you are saying it.
You make it enjoyable and you continue to take care of to stay it
wise. I can't wait to read much more from you. This is actually a wonderful website.

yeezy

I simply desired to thank you very much once again. I do not know the things that I would have implemented in the absence of the tactics discussed by you relating to that subject. This was a very hard case in my view, nevertheless witnessing this expert form you handled it made me to jump over gladness. Now i'm happy for this assistance and then wish you really know what a great job you have been undertaking instructing others via a site. I am sure you haven't got to know any of us.

Add new comment | arxic Drupal

First off I would like to say fantastic blog! I
had a quick question in which I'd like to ask if you do not mind.
I was interested to find out how you center yourself
and clear your head before writing. I have had a hard
time clearing my thoughts in getting my thoughts out there.
I do enjoy writing however it just seems like the first 10 to 15 minutes
are lost just trying to figure out how to begin. Any suggestions or tips?
Appreciate it!

supreme hoodie

I and also my guys were found to be going through the best tips and tricks found on your web blog while then I had an awful feeling I never expressed respect to the web site owner for those techniques. The young boys appeared to be glad to see all of them and already have very much been tapping into them. Many thanks for turning out to be so thoughtful and also for getting this sort of fabulous guides most people are really wanting to be informed on. Our own sincere regret for not expressing appreciation to you sooner.

fila online shop

I actually wanted to compose a simple word in order to appreciate you for the amazing ways you are giving here. My time-consuming internet investigation has now been honored with incredibly good points to write about with my company. I would claim that many of us site visitors are definitely blessed to be in a superb community with many awesome people with insightful plans. I feel truly fortunate to have used the web pages and look forward to many more entertaining minutes reading here. Thanks a lot once more for all the details.

supreme clothing

I intended to create you the little observation to be able to say thanks the moment again on your wonderful concepts you've provided on this site. It has been certainly shockingly open-handed of you to provide easily all that a lot of people would've marketed as an electronic book to earn some money for themselves, especially given that you might have tried it in the event you decided. Those creative ideas in addition worked like a easy way to be certain that many people have the same dream just as my very own to understand a good deal more regarding this issue. I know there are many more enjoyable instances up front for folks who read your website.

kyrie 6

Thanks for all of your effort on this web site. Kate takes pleasure in conducting research and it's simple to grasp why. I know all about the powerful manner you convey efficient strategies on this web blog and recommend participation from other ones about this situation so our own child is now understanding a great deal. Have fun with the remaining portion of the new year. You're performing a splendid job.

Add new comment | arxic Drupal

Thank you for the auspicious writeup. It in reality was a entertainment account it.
Look advanced to more brought agreeable from you! However,
how can we be in contact?

golden goose sneakers

My husband and i got now contented that Ervin could round up his analysis via the ideas he came across through your web pages. It's not at all simplistic to simply possibly be giving away concepts which often many others have been selling. And now we realize we have got the website owner to thank for that. The entire illustrations you have made, the simple site menu, the friendships you can help engender - it's many extraordinary, and it is assisting our son in addition to the family know that this situation is entertaining, and that's rather pressing. Thank you for all!

bape hoodie

I am only writing to let you know of the great discovery my cousin's girl developed studying your web site. She noticed some details, not to mention what it is like to have an awesome coaching style to have many people with no trouble learn selected grueling issues. You really exceeded her expected results. Thanks for presenting the good, trustworthy, educational and easy guidance on that topic to Janet.

Add new comment | arxic Drupal

After looking over a handful of the articles on your blog, I honestly like your technique
of writing a blog. I book marked it to my bookmark website list and will be checking back
soon. Take a look at my website too and tell me what you think.

birkin bag

I have to express my thanks to the writer just for bailing me out of this circumstance. As a result of exploring through the world wide web and meeting tips that were not pleasant, I figured my entire life was done. Being alive without the presence of solutions to the problems you've solved through your main guideline is a crucial case, and the kind which could have adversely affected my career if I hadn't encountered your blog post. Your skills and kindness in controlling all things was vital. I don't know what I would've done if I had not come across such a thing like this. I am able to at this time look ahead to my future. Thank you so much for your impressive and result oriented guide. I will not think twice to suggest your web site to any person who needs guidance about this problem.

balenciaga

I actually wanted to write down a brief word to appreciate you for some of the fantastic tips you are sharing here. My considerable internet look up has at the end been compensated with incredibly good ideas to talk about with my contacts. I would assume that many of us website visitors actually are very lucky to live in a really good community with many special people with helpful strategies. I feel very fortunate to have discovered the weblog and look forward to tons of more cool times reading here. Thanks a lot once more for all the details.

Add new comment | arxic Drupal

Hello! I know this is sort of off-topic but I needed to ask.
Does operating a well-established blog like yours require
a lot of work? I am brand new to writing
a blog however I do write in my journal on a daily basis.
I'd like to start a blog so I can easily share
my own experience and views online. Please let me know if you have any kind of ideas or tips for new aspiring blog owners.
Appreciate it!

balenciaga

I simply had to appreciate you all over again. I do not know the things that I would have handled in the absence of the actual methods shared by you regarding my theme. It became a frustrating matter in my position, nevertheless witnessing the very well-written way you solved the issue forced me to leap with delight. Now i am grateful for this help and thus hope you find out what a powerful job you're doing educating other individuals through a web site. More than likely you haven't got to know all of us.

air max 97

I precisely wanted to say thanks all over again. I do not know what I could possibly have carried out without the entire smart ideas shared by you concerning such industry. It previously was an absolute horrifying condition for me personally, but looking at the specialised manner you managed the issue took me to leap for fulfillment. I will be grateful for your assistance and thus trust you find out what a great job you're putting in instructing some other people with the aid of your websites. More than likely you have never come across all of us.

Add new comment | arxic Drupal

Thanks for the auspicious writeup. It in reality was once a
enjoyment account it. Look complex to more introduced
agreeable from you! However, how could we keep up a correspondence?

nike air vapormax

I am glad for writing to make you understand what a awesome experience my wife's daughter gained checking your webblog. She picked up numerous things, most notably what it is like to possess a wonderful giving style to make the others with no trouble have an understanding of various problematic subject areas. You undoubtedly surpassed people's desires. Many thanks for delivering these warm and helpful, trusted, explanatory and as well as easy guidance on your topic to Evelyn.

air jordans

I precisely had to thank you very much again. I'm not certain the things that I would've made to happen in the absence of these concepts provided by you on such subject. Completely was a real alarming scenario in my circumstances, nevertheless taking a look at the very expert style you dealt with it took me to leap over joy. I will be grateful for this information and thus expect you comprehend what a great job you're undertaking teaching many others with the aid of your webpage. More than likely you've never come across any of us.

golden goose

I am glad for commenting to let you understand of the extraordinary encounter our princess enjoyed reading through your blog. She came to find several issues, with the inclusion of what it is like to possess a great coaching heart to let other individuals without difficulty master several complicated subject matter. You really surpassed our own desires. Thanks for showing these helpful, healthy, informative and in addition easy tips on that topic to Lizeth.

Add new comment | arxic Drupal

Heya i am for the first time here. I came across this board
and I find It truly useful & it helped me out a lot.
I hope to give something back and help others like you helped
me.

supreme clothing

I wanted to put you a bit of word to finally thank you so much once again with your fantastic thoughts you've discussed in this case. This has been simply unbelievably generous with you in giving easily what a few people could have advertised as an e book to help with making some bucks for their own end, chiefly since you could have done it in the event you decided. Those principles likewise worked to be the easy way to fully grasp other people have a similar fervor just as my own to find out a lot more pertaining to this problem. I believe there are numerous more fun sessions up front for people who look over your blog post.

balenciaga shoes

Thanks a lot for providing individuals with an extremely wonderful possiblity to check tips from this web site. It's usually so enjoyable and as well , jam-packed with fun for me and my office colleagues to search your website the equivalent of three times in 7 days to find out the newest guides you will have. And indeed, I am just certainly pleased considering the tremendous tactics served by you. Some 3 points in this post are unequivocally the best we have all ever had.

supreme clothing

A lot of thanks for all of your efforts on this web page. My mother takes pleasure in managing research and it is easy to see why. We all know all concerning the dynamic ways you convey informative items on this website and as well as welcome response from other ones on that area of interest while our own princess is becoming educated a whole lot. Enjoy the rest of the new year. You are always performing a powerful job.

hermes belts

I simply had to thank you so much once again. I am not sure what I might have taken care of without the actual thoughts revealed by you relating to my question. Certainly was the scary circumstance in my circumstances, however , discovering the specialised style you processed it forced me to weep with delight. I will be grateful for this information as well as pray you realize what a powerful job you happen to be accomplishing instructing most people with the aid of your web page. Most probably you have never met all of us.

kyrie 3

I just wanted to jot down a quick note to be able to express gratitude to you for the splendid tricks you are giving out at this site. My particularly long internet search has at the end of the day been recognized with beneficial insight to talk about with my friends and classmates. I 'd mention that most of us site visitors actually are quite lucky to live in a useful community with very many lovely individuals with very helpful things. I feel extremely lucky to have encountered your entire weblog and look forward to so many more pleasurable times reading here. Thanks a lot again for everything.

golden goose

I needed to compose you the bit of observation in order to thank you very much over again relating to the beautiful things you've contributed on this page. This has been quite incredibly generous of you to make openly all that most people would've made available for an electronic book to earn some dough for their own end, most importantly considering that you could have done it if you ever decided. The techniques as well worked to be the great way to fully grasp that someone else have the identical keenness like mine to know significantly more around this condition. I am sure there are millions of more pleasant situations up front for folks who check out your site.

supreme

Thank you a lot for providing individuals with remarkably pleasant possiblity to read in detail from this blog. It is usually so terrific plus full of a good time for me and my office fellow workers to visit your website a minimum of 3 times in one week to read the latest things you have got. Not to mention, I'm just certainly impressed with all the excellent tactics served by you. Selected 2 areas on this page are in reality the most efficient we've had.

kyrie irving shoes

I actually wanted to make a word so as to express gratitude to you for all of the fabulous guidelines you are writing on this site. My long internet research has at the end been compensated with good content to write about with my pals. I would state that that many of us site visitors actually are undoubtedly fortunate to exist in a useful network with very many lovely people with beneficial plans. I feel rather happy to have used your site and look forward to plenty of more pleasurable times reading here. Thanks once again for a lot of things.

kyrie 5

I precisely had to appreciate you yet again. I am not sure the things that I would've taken care of without the type of tactics discussed by you relating to this subject matter. It seemed to be a real hard condition for me, however , considering the very professional way you managed that made me to leap with fulfillment. I'm grateful for this help and even wish you are aware of an amazing job you were accomplishing educating many people thru your webblog. Most probably you haven't encountered all of us.

adidas gazelle

I really wanted to post a small message so as to express gratitude to you for those pleasant facts you are sharing on this website. My extensive internet look up has at the end of the day been compensated with reliable facts to write about with my co-workers. I 'd believe that most of us site visitors are quite lucky to be in a superb network with very many marvellous individuals with insightful plans. I feel very much blessed to have come across your webpages and look forward to plenty of more brilliant moments reading here. Thanks a lot once again for a lot of things.

westbrook shoes

I and also my guys have already been checking out the good tactics from your web page while at once got an awful suspicion I never expressed respect to you for them. Most of the guys were as a consequence stimulated to see all of them and have in effect pretty much been making the most of them. Thanks for being well thoughtful and then for making a decision on this sort of wonderful topics millions of individuals are really desperate to understand about. Our sincere regret for not expressing appreciation to you sooner.

golden goose

I enjoy you because of your whole hard work on this web page. Gloria loves getting into investigation and it's easy to see why. Most of us know all relating to the powerful form you produce functional guidelines on your website and as well attract contribution from other ones about this subject matter then our own princess is starting to learn a whole lot. Take pleasure in the rest of the year. You are always performing a powerful job.

air jordan

Thank you a lot for providing individuals with an exceptionally spectacular possiblity to read articles and blog posts from here. It really is so amazing and full of a lot of fun for me and my office acquaintances to search your site no less than thrice in one week to read through the latest guides you have. And definitely, we are actually fulfilled for the unbelievable techniques you give. Selected 2 facts in this article are undoubtedly the very best we have all ever had.

hermes belt

I wanted to post you a very little observation so as to say thank you as before considering the breathtaking views you have provided here. It's simply seriously generous of you to grant freely all most people might have sold as an ebook to end up making some bucks for their own end, specifically considering the fact that you might well have done it if you ever desired. These solutions additionally worked to become great way to realize that most people have a similar keenness really like my own to figure out good deal more with regards to this issue. I am certain there are many more pleasurable sessions in the future for individuals who start reading your blog.

coach outlet

I must get across my respect for your kindness supporting women who really want help on that subject. Your very own dedication to getting the solution all over had become extraordinarily powerful and has specifically made somebody like me to reach their endeavors. Your amazing warm and friendly tips and hints denotes so much to me and even more to my peers. Regards; from all of us.

balenciaga sneakers

I wish to point out my appreciation for your kindness in support of men who really want help with the concern. Your very own commitment to passing the message across was definitely helpful and has frequently allowed regular people just like me to achieve their dreams. Your new useful help entails much a person like me and substantially more to my mates. Regards; from each one of us.

curry shoes

I simply wished to thank you so much yet again. I do not know the things that I would've accomplished without the creative ideas shown by you concerning my theme. It had become the troublesome setting for me personally, nevertheless being able to view your professional form you solved that forced me to leap over contentment. I'm happier for this service and even have high hopes you are aware of a great job you happen to be undertaking teaching other individuals through the use of your web blog. Most probably you have never met all of us.

Pages

Add new comment