# Allowing Material Quantities link to multiple Material Taxonomy Terms

**URL:** <https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618>\
**Category:** Development\
**Tags:** feature-request\
**Created:** [April 13, 2023, 5:42pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618 "2023-04-13T17:42:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbathree](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/gbathree/32/286_2.png) [@gbathree](https://farmos.discourse.group/u/gbathree)\
**Post date:** [April 13, 2023, 5:42pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/1 "2023-04-13T17:42:59Z")

</div>

So I’m using the Material Quantity type pretty extensively and the Material Taxonomy list. I’ve hit a snag, which is **currently you may only link a single Material Taxonomy term to a Material Quantity log.** In my cases, I’m using this field primarily as a reference for the types of materials included in this quantity. So I could add a herbicide named ‘greg’s horrible herbicide’, and enter:

- Quantity
  - value: 10
  - relationships
    - material
      - herbicide
      - greg’s horrible herbicide

Another example: I’m adding mixes of products - a mix of fertilizers “hog manure”, “cow manure”, “chicken manure”.

- Quantity
  - value: 10
  - relationships
    - material
      - hog manure
      - cow manure
      - chicken manure

I know that if I were doing inventory tracking, this conceptually wouldn’t make sense because I don’t know of the ‘value: 10’ which parts apply to which manure type. But I don’t care and I don’t even know, what I care about is knowing the component parts of whatever I applied (I might not even have a `value`! Sometimes I just use the quantity to reference material taxonomy terms).

Workarounds like making 3 different quantities and adding the `value: 10` to one of them are wonky and furthermore provide inaccurate information (I didn’t add `value: 10` for just the hog manure and nothing of the rest… it was a mix…). I also don’t want to use comma separate values, because you end up with a mess in your material taxonomy terms which I really want to effectively use.

**So… would allowing `material` to reference multiple `taxonomy_term--material` cause issues / break anything in your modules / code?** (remember, currently it allows only 1 reference).

I hope this is a small change, but I wanted to ask and see if anyone felt this could break something.

Thanks for the feedback!

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [April 13, 2023, 7:52pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/2 "2023-04-13T19:52:37Z")

</div>

Makes sense to me. I think the main question will be whether or not this is a “breaking change”. I don’t _think_ it would be, but I’ll have to take a closer look…

> **[Material assets, types, quantities, inventory, and filtering](https://www.drupal.org/project/farm/issues/3196834)**
>
> Problem/Motivation Follow-up to: \[#3196825\] In farmOS 1.x, Input logs have a "Materials" field, which is used to reference terms in the "Materials" vocabulary. This allows users to categorize their Input logs based on the materials used for easier...

It’s funny because you’re essentially asking for something we had in farmOS v1… which was too limited/ambiguous (couldn’t track granular quantity of each ingredient in a mix) and was the motivation for moving the material type reference to the `quantity`.

But when we did that, we just assumed that single term references were the only requirement. But what your describing does make sense… as a slightly less granular way of recording things… similar to v1, but still on the quantity.

---

<div class="post-metadata">

**Author:** ![gbathree](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/gbathree/32/286_2.png) [@gbathree](https://farmos.discourse.group/u/gbathree)\
**Post date:** [April 14, 2023, 4:06pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/3 "2023-04-14T16:06:08Z")

</div>

I think specifying down to 1 could also be a very reasonable convention, in a certain management system also.

---

<div class="post-metadata">

**Author:** ![gbathree](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/gbathree/32/286_2.png) [@gbathree](https://farmos.discourse.group/u/gbathree)\
**Post date:** [April 27, 2023, 5:06pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/4 "2023-04-27T17:06:06Z")

</div>

Discussed in the FarmOS call 4/27/2023… turns out there is a breaking change because `relationships.materials` in the API goes from being a single object to an array :\ bummer that’s a breaking change.

So we’ll add a request for FarmOS 3.x, and we’ll add a module to change it in SurveyStack managed instances and other farmers using these tools.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [April 27, 2023, 7:13pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/5 "2023-04-27T19:13:17Z")

</div>

Added a link to this from our 3.x tracking issue, so we don’t forget: [[META] farmOS 3.x Breaking Changes [#3347412] | Drupal.org](https://www.drupal.org/project/farm/issues/3347412#comment-15027622)

I think next steps we discussed were:

1. Open a dedicated [farmOS | Drupal.org](http://drupal.org/project/farm) issue for making this change, with a patch or merge request, and mark the status as “Postponed” - so it’s ready to merge when the 3.x branch is opened.
2. Enable altering of bundle fields (needs an issue of it’s own).
3. Create a contrib “shim” module that alters the core material reference field definition to set `'multiple' => TRUE` - for instances that want to enable this before 3.x.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [May 2, 2023, 4:40pm UTC](https://farmos.discourse.group/t/allowing-material-quantities-link-to-multiple-material-taxonomy-terms/1618/6 "2023-05-02T16:40:54Z")

</div>

> 1. Open a dedicated [farmOS | Drupal.org](http://drupal.org/project/farm) issue for making this change, with a patch or merge request, and mark the status as “Postponed” - so it’s ready to merge when the 3.x branch is opened.

I created this issue, with a merge request: [Client Challenge](https://www.drupal.org/project/farm/issues/3357679)

And linked it to our meta 3.x issue here: [Client Challenge](https://www.drupal.org/project/farm/issues/3347412)

> [@mstenta](#):
>
> Enable altering of bundle fields (needs an issue of it’s own).

Created an issue for this as well: [Client Challenge](https://www.drupal.org/project/farm/issues/3357686)
