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

golden goose sneakers

There are certainly plenty of particulars like that to take into consideration. That may be a nice point to convey up. I supply the thoughts above as normal inspiration however clearly there are questions just like the one you convey up the place an important thing will be working in trustworthy good faith. I don?t know if best practices have emerged around issues like that, but I'm positive that your job is clearly recognized as a good game. Both girls and boys feel the impression of just a moment抯 pleasure, for the rest of their lives.

Add new comment | arxic Drupal

Thank you for some other excellent post. The place else may anyone get that type
of info in such a perfect manner of writing? I have a presentation subsequent week, and I am on the search for such information.

kobe shoes

you could have an important blog right here! would you wish to make some invite posts on my weblog?

timberland boots

I not to mention my pals were actually looking at the nice helpful hints from your web page and then all of the sudden I got an awful suspicion I had not thanked the web site owner for those strategies. Those ladies were definitely thrilled to read them and already have clearly been tapping into these things. I appreciate you for simply being really considerate and then for getting this form of tremendous topics most people are really eager to be informed on. My personal sincere regret for not saying thanks to you earlier.

Add new comment | arxic Drupal

Howdy this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you
have to manually code with HTML. I'm starting a blog soon but have no coding expertise so I wanted to get advice from
someone with experience. Any help would be greatly appreciated!

curry 6

I would like to express appreciation to this writer for rescuing me from this type of trouble. Just after looking throughout the the net and obtaining techniques which are not productive, I figured my life was well over. Living without the answers to the issues you've fixed as a result of your report is a serious case, as well as those which may have in a negative way damaged my career if I had not encountered the blog. Your good ability and kindness in playing with every item was very helpful. I don't know what I would have done if I had not come upon such a point like this. It's possible to at this time look forward to my future. Thanks very much for the professional and effective help. I won't think twice to propose your blog to any person who would need counselling about this issue.

kobe shoes

I wanted to send you one tiny note just to say thanks a lot over again for all the incredible pointers you've documented on this page. It is so surprisingly generous of you to supply easily what exactly most of us would have offered for an electronic book to earn some dough for their own end, most notably seeing that you might well have done it in the event you decided. These smart ideas likewise worked to become fantastic way to know that many people have the identical keenness similar to mine to understand lots more with reference to this matter. I'm certain there are many more enjoyable instances up front for many who scan your blog post.

Add new comment | arxic Drupal

I love your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do
it for you? Plz reply as I'm looking to design my own blog and would like to
know where u got this from. thank you

calvin klein outlet

I'm just writing to make you understand what a extraordinary encounter my friend's child obtained checking your web site. She mastered a wide variety of issues, with the inclusion of what it is like to have a wonderful coaching nature to make the mediocre ones very easily thoroughly grasp chosen tricky matters. You really exceeded readers' desires. Thanks for churning out such essential, trusted, educational and in addition fun tips about that topic to Kate.

Add new comment | arxic Drupal

You really make it appear so easy with your presentation but I find this topic to
be really one thing which I feel I would by no means understand.
It kind of feels too complex and extremely extensive for me.
I am taking a look forward in your next submit, I'll attempt to get
the hold of it!

kd 12 shoes

My wife and i ended up being contented Chris could finish up his homework by way of the precious recommendations he obtained through your web pages. It is now and again perplexing to simply continually be giving for free facts some others could have been selling. And we already know we now have the blog owner to appreciate for that. Those illustrations you made, the straightforward blog menu, the friendships you will assist to instill - it's many unbelievable, and it's letting our son in addition to the family do think that subject is satisfying, which is tremendously pressing. Many thanks for the whole lot!

Add new comment | arxic Drupal

What i do not understood is in fact how you're now not really a lot more smartly-preferred than you might be right now.
You're very intelligent. You already know thus considerably in relation to this matter, produced
me individually imagine it from so many various angles.
Its like men and women are not interested unless it's something to accomplish with Woman gaga!
Your own stuffs great. All the time deal with it up!

michael kors outlet

I and also my friends ended up reviewing the nice helpful tips from the blog while suddenly I had an awful feeling I had not expressed respect to you for those techniques. The men became so stimulated to study them and have in effect simply been having fun with those things. Thank you for being well helpful and then for choosing this sort of excellent tips most people are really eager to be aware of. My very own honest regret for not saying thanks to sooner.

Add new comment | arxic Drupal

great points altogether, you simply received a emblem new reader.
What could you suggest about your post that you just made a few days ago?

Any positive?

yeezy boost 350

Needed to send you the bit of remark just to thank you over again considering the precious basics you've shared in this article. It's really open-handed with you to give publicly all a number of us might have marketed for an e-book to earn some dough on their own, notably considering the fact that you could have tried it in case you considered necessary. These advice additionally acted like the fantastic way to comprehend many people have the same passion much like my own to learn whole lot more with regard to this condition. I'm sure there are lots of more pleasurable occasions up front for many who read carefully your website.

Add new comment | arxic Drupal

Admiring the commitment you put into your website and
in depth information you offer. It's nice to come
across a blog every once in a while that isn't the same unwanted rehashed material.
Great read! I've bookmarked your site and I'm adding your RSS feeds to my Google account.

nike air max 2017

I together with my guys have been examining the excellent helpful hints found on your web site while at once got a terrible suspicion I never expressed respect to the site owner for those strategies. My guys appeared to be certainly happy to read all of them and have in effect unquestionably been using them. Appreciation for indeed being indeed considerate as well as for picking variety of helpful issues millions of individuals are really needing to discover. Our own sincere apologies for not expressing appreciation to you sooner.

Add new comment | arxic Drupal

When someone writes an piece of writing he/she maintains the
plan of a user in his/her mind that how a user can be aware of it.
Thus that's why this paragraph is amazing. Thanks!

coach handbags

My wife and i were now glad when Ervin could do his homework by way of the ideas he made from your weblog. It is now and again perplexing just to always be handing out tactics people may have been making money from. And now we take into account we now have the writer to appreciate for this. Most of the illustrations you made, the easy blog navigation, the friendships you assist to create - it's everything powerful, and it's really aiding our son and the family reason why the subject matter is enjoyable, which is especially fundamental. Thanks for all the pieces!

moncler outlet

My wife and i have been quite delighted Ervin could round up his analysis via the precious recommendations he was given through the site. It is now and again perplexing to simply happen to be releasing secrets which often some people may have been trying to sell. So we already know we need the writer to give thanks to for this. These illustrations you've made, the simple site navigation, the relationships your site make it easier to engender - it's mostly sensational, and it's leading our son in addition to us imagine that the matter is brilliant, and that is truly indispensable. Thanks for everything!

Add new comment | arxic Drupal

always i used to read smaller content which as well clear their motive, and that is also
happening with this paragraph which I am reading at this place.

yeezy boost 350 v2

I simply wished to thank you so much once again. I do not know the things that I might have used in the absence of the actual suggestions revealed by you concerning that topic. It was actually an absolute frustrating condition for me personally, nevertheless coming across your specialized technique you resolved that made me to leap with joy. I'm happy for this information and wish you really know what a great job that you are putting in educating others by way of your web site. Most probably you have never encountered all of us.

Add new comment | arxic Drupal

Great website. Lots of helpful info here. I am sending it to
several buddies ans additionally sharing in delicious.
And naturally, thanks on your effort!

nike air max 270

Thank you a lot for providing individuals with an extremely pleasant chance to read critical reviews from this site. It really is so pleasurable and as well , packed with a good time for me and my office colleagues to visit your web site at least three times in a week to read through the fresh guidance you have got. And of course, I'm always amazed with all the incredible tricks served by you. Some 4 tips on this page are in fact the most impressive we have had.

Add new comment | arxic Drupal

Hello there! I could have sworn I've been to this website before but after
going through some of the articles I realized it's new to me.
Anyhow, I'm definitely delighted I came across it and I'll be book-marking it and
checking back often!

supreme clothing

I want to convey my admiration for your kind-heartedness for men and women who require help on the matter. Your real dedication to passing the message all over turned out to be amazingly helpful and have really enabled workers like me to arrive at their dreams. The interesting recommendations indicates so much a person like me and somewhat more to my fellow workers. Regards; from all of us.

Add new comment | arxic Drupal

I was wondering if you ever considered changing the structure of your website?
Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people
could connect with it better. Youve got an awful lot of text for only having
one or 2 pictures. Maybe you could space it out better?

lebron shoes

A lot of thanks for your whole effort on this web page. Debby take interest in getting into investigation and it's easy to understand why. We all hear all regarding the lively way you produce vital steps via the website and as well as foster contribution from website visitors on that subject matter and my simple princess is in fact understanding a lot. Take pleasure in the remaining portion of the new year. You are always doing a tremendous job.

Add new comment | arxic Drupal

It's the best time to make some plans for the future and it's time
to be happy. I have read this post and if I could I desire
to suggest you few interesting things or suggestions.
Perhaps you can write next articles referring to this article.
I desire to read more things about it!

westbrook shoes

I must get across my passion for your kind-heartedness supporting persons that actually need help with this one study. Your real dedication to passing the solution around had been extremely beneficial and have continually permitted many people like me to reach their goals. Your own interesting instruction implies a whole lot to me and additionally to my fellow workers. With thanks; from each one of us.

Add new comment | arxic Drupal

Its like you read my mind! You seem to know so much about this, like
you wrote the book in it or something. I think that you can do
with some pics to drive the message home a little bit, but instead
of that, this is great blog. An excellent read. I'll definitely be back.

nike kyrie 5

Thank you for all of your efforts on this web site. Ellie enjoys making time for investigations and it's easy to see why. We all hear all about the compelling method you convey priceless solutions on the web site and even recommend contribution from others on that topic so our own girl is without a doubt studying a lot. Enjoy the remaining portion of the new year. You are performing a brilliant job.

Add new comment | arxic Drupal

Spot on with this write-up, I absolutely believe this website needs far more attention. I'll probably be back again to read more, thanks for the
info!

coach outlet

I must show my thanks to you for rescuing me from this type of trouble. After browsing throughout the search engines and coming across principles that were not powerful, I was thinking my entire life was done. Being alive devoid of the solutions to the issues you've resolved by way of your entire report is a crucial case, and ones which might have badly damaged my entire career if I had not encountered your web blog. Your actual skills and kindness in dealing with all the details was crucial. I'm not sure what I would've done if I hadn't come upon such a stuff like this. I'm able to at this moment relish my future. Thanks very much for the skilled and amazing guide. I won't be reluctant to propose your blog to any person who desires recommendations on this problem.

Add new comment | arxic Drupal

I'm now not certain where you're getting your info, but
great topic. I must spend a while studying more or working out more.
Thank you for magnificent information I used
to be looking for this info for my mission.

lebron shoes

I and my guys were actually looking at the good hints found on your site while all of the sudden developed a terrible suspicion I never expressed respect to you for those strategies. These boys appeared to be for this reason very interested to read through them and have now quite simply been taking advantage of those things. Thank you for really being considerably helpful and also for choosing such amazing subject areas millions of individuals are really needing to be informed on. Our own honest apologies for not expressing gratitude to sooner.

Add new comment | arxic Drupal

Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you! By the way, how can we communicate?

supreme hoodie

Aw, this was a really nice post. In thought I want to put in writing like this moreover ?taking time and actual effort to make a very good article?but what can I say?I procrastinate alot and under no circumstances seem to get something done.

Add new comment | arxic Drupal

Hello, Neat post. There's a problem together with your site in web
explorer, might check this? IE nonetheless is the marketplace leader and
a large component of people will leave out your wonderful writing due to this problem.

yeezy boost

I used to be very happy to seek out this web-site.I wished to thanks on your time for this wonderful read!! I positively having fun with every little bit of it and I've you bookmarked to check out new stuff you blog post.

longchamp bags

This web site can be a walk-via for all the information you needed about this and didn抰 know who to ask. Glimpse here, and you抣l definitely discover it.

Add new comment | arxic Drupal

This is very interesting, You are a very skilled blogger.
I've joined your feed and look forward to
seeking more of your excellent post. Also, I've shared
your site in my social networks!

balenciaga

When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get 4 emails with the identical comment. Is there any manner you can take away me from that service? Thanks!

Add new comment | arxic Drupal

First of all I want to say fantastic blog! I had a quick
question which I'd like to ask if you don't mind.
I was curious to know how you center yourself and clear your mind before writing.
I have had a difficult time clearing my mind in getting my thoughts out there.
I truly do enjoy writing but it just seems like the first 10 to 15 minutes are usually lost just trying to figure out how to begin. Any ideas or tips?
Kudos!

Pages

Add new comment