<p>You can assign ingredients to recipes using the built-in <a href="http://buildwithcraft.com/docs/entries-fields">Entries</a> field type.</p>

<p>Then, to view which recipes an ingredient is used on, check out the <a href="https://github.com/iainurquhart/craft_introvert">Introvert</a> plugin. It gives you a new field type that can be used to simply show reverse relationships, also providing links to edit those other entries.</p>

CC BY-SA 3.0
2014-07-01T22:13:23.637Z
Thanks for the Response Brandon. This is about half way there.

The client has requested the editing be a two way street, meaning that they be able to add and remove associated recipes from the ingredients edit screen.

This is beneficial because say they were to add a new ingredient, they can quickly associate it with all applicable recipes rather than having to open each individual recipe and add it there.
Peter Tell
CC BY-SA 3.0
2014-07-01T22:16:29.143Z
Ah, yeah. Currently that’s not possible with Introvert. Feature request!
Brandon Kelly
CC BY-SA 3.0
2014-07-01T21:16:56.420Z
2014-07-01T21:16:56.420Z
Brandon Kelly
<p>There's still a few kinks to work out, but I developed a plugin that solves this problem using Craft's native Many to Many relationship that already exists.</p>

<p>Basically, I've created a field type that links the relationship from the other side of things and allows you to add entries to it.</p>

<p>You can find it here:
<a href="https://github.com/page-8/craft-manytomany" rel="nofollow noreferrer">https://github.com/page-8/craft-manytomany</a></p>

<p>Thanks <a href="https://craftcms.stackexchange.com/users/9/brandon-kelly">@Brandon Kelly</a> for the help and guidance.</p>

CC BY-SA 3.0
2014-07-12T23:34:56.390Z
Great Peter, nice work! Go ahead and submit that to [Straight Up Craft](http://straightupcraft.com/craft-plugins), if you haven't already... I'm sure others would find it useful as well! :)
Lindsey D
CC BY-SA 3.0
2014-07-13T01:14:56.303Z
Good call Lindsey. Done and done.
Peter Tell
CC BY-SA 3.0
2014-07-12T17:27:28.287Z
2014-07-12T17:27:28.287Z
2017-04-13T12:51:00.200Z
Peter Tell
<p>So, for example:</p>

<p>Say I have two sections:</p>

<pre><code>- Recipes
- Ingredients
</code></pre>

<p>Recipes can have many ingredients. Ingredients can have many recipes.</p>

<p>If I'm editing a Recipe, I can edit the ingredients. This updates the relationship so that when I edit ingredients it can show the associated recipes (and they are editable from the ingredients as well).</p>

<p>Is this possible with Craft?</p>

<p>Thanks!</p>

<p>====== EDIT ======</p>

<p>Just to make this more clear. What I'm trying to do is create a Many to Many relationship between two Sections of Entries so there is an association between the two that works both ways.</p>

<p>Another example of this would be if you have a User with many Roles. I can manage which Users belong to which Roles from the Roles section, and/or I could manage which Roles a User belongs to from the Users section.</p>

<entries><relations>
Is it possible to create a fieldtype that creates a many to many relationship between two entry sections?
# Is it possible to create a fieldtype that creates a many to many relationship between two entry sections?

(Asked by: username_0 on 2014-07-01)

So, for example:
Say I have two sections:
- Recipes
- Ingredients

Recipes can have many ingredients. Ingredients can have many recipes.
If I'm editing a Recipe, I can edit the ingredients. This updates the relationship so that when I edit ingredients it can show the associated recipes (and they are editable from the ingredients as well).
Is this possible with Craft?
Thanks!
====== EDIT ======
Just to make this more clear. What I'm trying to do is create a Many to Many relationship between two Sections of Entries so there is an association between the two that works both ways.
Another example of this would be if you have a User with many Roles. I can manage which Users belong to which Roles from the Roles section, and/or I could manage which Roles a User belongs to from the Users section.

**Tags:** entries, relations


---

## 2 answers

### Answer by username_0 on 2014-07-12. Score: 7 | Accepted answer

There's still a few kinks to work out, but I developed a plugin that solves this problem using Craft's native Many to Many relationship that already exists.

Basically, I've created a field type that links the relationship from the other side of things and allows you to add entries to it.

You can find it here:
<https://github.com/page-8/craft-manytomany>

Thanks [@username_1](https://craftcms.stackexchange.com/users/9/brandon-kelly) for the help and guidance.

> **Comments:**
> **username_2**: Great Peter, nice work! Go ahead and submit that to [Straight Up Craft](http://straightupcraft.com/craft-plugins), if you haven't already... I'm sure others would find it useful as well! :)  
> **username_0**: Good call Lindsey. Done and done.  

---

### Answer by username_1 on 2014-07-01. Score: 6

You can assign ingredients to recipes using the built-in [Entries](http://buildwithcraft.com/docs/entries-fields) field type.

Then, to view which recipes an ingredient is used on, check out the [Introvert](https://github.com/iainurquhart/craft_introvert) plugin. It gives you a new field type that can be used to simply show reverse relationships, also providing links to edit those other entries.

> **Comments:**
> **username_0**: Thanks for the Response Brandon. This is about half way there.  The client has requested the editing be a two way street, meaning that they be able to add and remove associated recipes from the ingredients edit screen.  This is beneficial because say they were to add a new ingredient, they can quickly associate it with all applicable recipes rather than having to open each individual recipe and add it there.  
> **username_1**: Ah, yeah. Currently that’s not possible with Introvert. Feature request!  

---

