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

spongebob kyrie 5

An impressive share, I just given this onto a colleague who was doing a bit of evaluation on this. And he the truth is purchased me breakfast because I found it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If attainable, as you turn into experience, would you thoughts updating your blog with extra details? It's highly helpful for me. Massive thumb up for this blog submit!

nike max

I抎 should test with you here. Which isn't one thing I often do! I get pleasure from reading a publish that can make people think. Also, thanks for allowing me to comment!

Add new comment | arxic Drupal

Hi, Neat post. There is an issue along with your
web site in internet explorer, would check this? IE nonetheless is the marketplace chief and a huge section of people will miss your excellent writing because of this problem.

jordan shoes

This website is really a stroll-by for all of the information you needed about this and didn抰 know who to ask. Glimpse right here, and also you抣l positively uncover it.

Add new comment | arxic Drupal

Hey There. I found your blog using msn. This is a really well written article.
I will be sure to bookmark it and come back to read more of your
useful info. Thanks for the post. I will definitely return.

converse outlet

I and also my pals appeared to be reviewing the excellent suggestions from the blog while then I got a horrible suspicion I had not expressed respect to the web blog owner for those strategies. The young boys ended up as a result excited to learn all of them and have now certainly been having fun with those things. Thanks for really being quite considerate and then for picking this form of cool ideas most people are really desirous to discover. Our own honest apologies for not expressing gratitude to you sooner.

Add new comment | arxic Drupal

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

polo ralph lauren

I not to mention my pals were reviewing the good tips and hints from your site and so then developed a terrible feeling I never expressed respect to the web blog owner for those tips. Those ladies were certainly happy to see all of them and have now without a doubt been loving them. We appreciate you being really kind as well as for going for certain really good themes most people are really desperate to be informed on. Our sincere apologies for not saying thanks to earlier.

balenciaga sneakers

I simply needed to say thanks once again. I am not sure what I could possibly have handled without the type of tips documented by you about such a theme. It was a real troublesome problem in my opinion, nevertheless encountering this specialised strategy you dealt with that forced me to leap with gladness. Extremely happier for the information and thus believe you comprehend what a powerful job you are undertaking instructing people today through a blog. I'm certain you've never met any of us.

Add new comment | arxic Drupal

Hi there just wanted to give you a quick heads up and let you know a few of the images aren't loading correctly.
I'm not sure why but I think its a linking issue.

I've tried it in two different web browsers and both show the same outcome.

jordans

Thank you for your entire effort on this web page. Betty delights in managing research and it is obvious why. A lot of people hear all concerning the powerful mode you create valuable items by means of the website and as well invigorate contribution from other people on this idea plus our child is without question studying a lot of things. Enjoy the remaining portion of the year. You are always performing a very good job.

calvin klein outlet

I have to show my love for your kindness in support of those people who need help on that area of interest. Your very own dedication to passing the message around was remarkably invaluable and have continually allowed regular people just like me to attain their pursuits. Your own important facts can mean a whole lot to me and even more to my peers. With thanks; from all of us.

Add new comment | arxic Drupal

Have you ever thought about creating an ebook or guest authoring on other sites?
I have a blog based upon on the same topics you discuss and would really
like to have you share some stories/information.
I know my readers would value your work.
If you are even remotely interested, feel free to send me an email.

coach outlet

I want to point out my appreciation for your kind-heartedness giving support to persons who need assistance with this one question. Your personal commitment to passing the solution all around has been pretty good and have made girls much like me to achieve their objectives. Your amazing invaluable guidelines denotes so much a person like me and far more to my peers. Regards; from everyone of us.

Add new comment | arxic Drupal

you're truly a just right webmaster. The website loading speed is incredible.
It seems that you are doing any unique trick. Also, The contents are masterpiece.
you've done a excellent job on this matter!

supreme shirt

I am commenting to let you know what a amazing encounter my cousin's princess undergone using your site. She learned a lot of details, not to mention what it is like to have a great coaching spirit to let a number of people clearly know some extremely tough subject matter. You truly surpassed our expectations. Thank you for rendering these productive, healthy, informative and in addition easy tips about your topic to Julie.

Add new comment | arxic Drupal

I'm not sure where you are getting your information, but good
topic. I needs to spend some time learning more or understanding more.

Thanks for magnificent info I was looking for this information for my mission.

ultra boost

I am just writing to make you know of the superb discovery my cousin's girl developed going through your web page. She learned lots of issues, with the inclusion of how it is like to have an incredible giving heart to make many people with no trouble learn selected hard to do matters. You really surpassed our own expected results. Thank you for distributing the important, trustworthy, educational not to mention easy tips on that topic to Ethel.

Add new comment | arxic Drupal

It is truly a great and helpful piece of information. I'm
satisfied that you just shared this helpful information with us.
Please keep us up to date like this. Thank you for sharing.

yeezy

I needed to write you the tiny observation so as to give thanks the moment again for the stunning methods you have contributed on this site. It was simply incredibly generous of people like you to make unhampered all some people might have supplied for an e-book to help with making some bucks for their own end, especially now that you might have tried it in the event you desired. The tricks as well acted to provide a fantastic way to realize that other people online have the same dream much like my personal own to know the truth more and more in regard to this condition. I'm sure there are millions of more enjoyable times up front for individuals who check out your website.

Add new comment | arxic Drupal

Thanks , I've just been looking for info approximately this topic for a while and yours is
the greatest I've came upon so far. However,
what about the bottom line? Are you sure about the source?

kyrie 5 shoes

I wish to voice my affection for your kind-heartedness in support of men who absolutely need help with your study. Your real commitment to passing the solution all-around has been exceptionally insightful and have all the time permitted women just like me to attain their desired goals. Your personal invaluable recommendations signifies so much a person like me and somewhat more to my office workers. Thanks a lot; from each one of us.

Add new comment | arxic Drupal

Greate article. Keep posting such kind of info on your site.
Im really impressed by your blog.
Hi there, You've performed an incredible job. I will definitely digg it and in my view recommend to my friends.
I am confident they will be benefited from this website.

supreme clothing

I must show appreciation to this writer just for bailing me out of such a situation. After checking throughout the search engines and finding views that were not beneficial, I thought my life was gone. Being alive devoid of the answers to the issues you have fixed by way of your good article content is a crucial case, as well as the ones which may have negatively affected my career if I hadn't noticed your website. The capability and kindness in touching all the things was precious. I'm not sure what I would have done if I hadn't come across such a step like this. I can at this moment relish my future. Thank you so much for your reliable and result oriented help. I won't hesitate to refer your blog post to anyone who requires assistance on this subject.

moncler jackets

I really wanted to send a simple word to express gratitude to you for the precious strategies you are showing on this website. My considerable internet search has now been compensated with extremely good details to go over with my close friends. I 'd suppose that we website visitors are very much lucky to live in a fine website with so many wonderful people with beneficial hints. I feel very much grateful to have come across the web page and look forward to so many more entertaining times reading here. Thank you once again for everything.

goyard handbags

I truly wanted to construct a simple note to be able to say thanks to you for all of the superb pointers you are giving out at this website. My time-consuming internet search has at the end of the day been rewarded with beneficial know-how to exchange with my relatives. I 'd tell you that most of us readers actually are undoubtedly endowed to dwell in a really good network with many awesome individuals with insightful solutions. I feel really grateful to have come across your webpages and look forward to really more amazing minutes reading here. Thank you once more for everything.

Add new comment | arxic Drupal

I believe everything posted was very reasonable. However,
what about this? suppose you composed a catchier title?
I am not suggesting your information is not solid.,
but what if you added a post title that grabbed folk's
attention? I mean Add new comment | arxic Drupal is kinda boring.
You ought to peek at Yahoo's home page and see how they create news titles to get viewers interested.
You might add a related video or a picture or two to get readers excited about everything've written. Just my opinion, it might bring your posts a little bit more interesting.

michael kors outlet

I wanted to create you a bit of word in order to say thanks a lot again on the wonderful secrets you've discussed on this page. It was quite remarkably open-handed with you to convey openly just what a few people would have distributed as an e book to help with making some cash on their own, certainly given that you could possibly have tried it in the event you desired. Those pointers additionally acted to be a good way to know that many people have the identical dream similar to mine to realize significantly more pertaining to this condition. I'm sure there are several more enjoyable situations ahead for folks who scan your site.

Add new comment | arxic Drupal

I’m not that much of a internet reader to be honest but your sites really nice, keep it up!
I'll go ahead and bookmark your site to come back later
on. All the best

offwhite

Thanks a lot for providing individuals with an extremely pleasant chance to discover important secrets from this blog. It is often very pleasant and as well , packed with amusement for me personally and my office co-workers to search the blog particularly 3 times in one week to learn the fresh things you will have. And of course, I'm so actually contented with your breathtaking opinions you give. Selected 1 ideas in this article are unquestionably the most effective I have ever had.

birkin bag

I really wanted to write down a message to be able to express gratitude to you for all of the fabulous tips you are sharing here. My long internet search has now been recognized with really good suggestions to share with my best friends. I 'd suppose that many of us website visitors actually are really endowed to exist in a remarkable site with so many brilliant people with beneficial tips and hints. I feel quite fortunate to have used your web pages and look forward to really more excellent times reading here. Thanks once again for all the details.

Add new comment | arxic Drupal

Having read this I believed it was really enlightening.
I appreciate you spending some time and energy to put this informative article together.

I once again find myself personally spending a significant amount of time both reading
and posting comments. But so what, it was still worthwhile!

bape hoodie

Thanks a lot for providing individuals with such a special opportunity to read critical reviews from this web site. It really is very cool and as well , full of a great time for me personally and my office mates to search your blog minimum 3 times in a week to see the newest items you have got. And indeed, I am also at all times fulfilled with your amazing methods you serve. Selected two points in this post are definitely the finest we have ever had.

kyrie 5

I want to express appreciation to the writer just for rescuing me from this type of challenge. Because of surfing around throughout the internet and obtaining advice that were not beneficial, I assumed my life was well over. Existing without the answers to the problems you've fixed through your entire article is a critical case, and ones which could have in a negative way damaged my entire career if I hadn't discovered your blog. Your own personal ability and kindness in dealing with almost everything was helpful. I don't know what I would have done if I hadn't come across such a stuff like this. I can also at this moment relish my future. Thanks for your time so much for the impressive and results-oriented help. I won't be reluctant to recommend your web sites to anyone who should get care about this situation.

Add new comment | arxic Drupal

Hi there! Someone in my Myspace group shared this site with
us so I came to take a look. I'm definitely loving the information.
I'm bookmarking and will be tweeting this to my followers!

Terrific blog and outstanding style and design.

balenciaga sneakers

I have to express some thanks to this writer just for rescuing me from this issue. Just after checking through the the web and getting techniques which were not beneficial, I believed my life was done. Living without the presence of approaches to the issues you have solved as a result of your article content is a crucial case, and those that could have in a wrong way affected my career if I hadn't come across your web blog. The competence and kindness in dealing with almost everything was useful. I don't know what I would've done if I hadn't discovered such a stuff like this. It's possible to now look forward to my future. Thanks very much for your expert and amazing guide. I will not hesitate to propose your blog post to anybody who needs and wants direction about this problem.

Add new comment | arxic Drupal

Excellent goods from you, man. I have understand your stuff previous to and you're just too great.

I really like what you've acquired here, really like what
you are saying and the way in which you say it.
You make it entertaining and you still take care of to keep it sensible.
I can not wait to read much more from you. This is actually
a terrific site.

golden goose

There are certainly loads of particulars like that to take into consideration. That could be a nice point to carry up. I provide the thoughts above as basic inspiration but clearly there are questions just like the one you bring up the place crucial thing shall be working in trustworthy good faith. I don?t know if greatest practices have emerged round issues like that, however I'm sure that your job is clearly recognized as a fair game. Each girls and boys really feel the affect of only a second抯 pleasure, for the remainder of their lives.

Add new comment | arxic Drupal

Thank you for the good writeup. It actually was once a enjoyment account it.
Look complex to far brought agreeable from you!
However, how could we keep in touch?

Add new comment | arxic Drupal

I don't know if it's just me or if everybody else experiencing problems with your blog.
It looks like some of the written text in your posts are running off the screen. Can somebody else please provide feedback and let me know if
this is happening to them too? This may be a problem with my web browser because I've
had this happen previously. Kudos

red bottom shoes

Nice post. I study something tougher on totally different blogs everyday. It'll at all times be stimulating to learn content material from other writers and apply just a little something from their store. I抎 desire to make use of some with the content on my weblog whether you don抰 mind. Natually I抣l offer you a hyperlink in your internet blog. Thanks for sharing.

Pages

Add new comment