# Does this exist: Save values as "presets" on assets to apply to logs associated with them

**URL:** <https://farmos.discourse.group/t/does-this-exist-save-values-as-presets-on-assets-to-apply-to-logs-associated-with-them/2603>\
**Category:** Development\
**Created:** [September 15, 2026, 8:46pm UTC](https://farmos.discourse.group/t/does-this-exist-save-values-as-presets-on-assets-to-apply-to-logs-associated-with-them/2603 "2026-09-15T20:46:48Z")\
**Posts on this page:** 2\
**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:** [September 15, 2026, 8:46pm UTC](https://farmos.discourse.group/t/does-this-exist-save-values-as-presets-on-assets-to-apply-to-logs-associated-with-them/2603/1 "2026-09-15T20:46:48Z")

</div>

I’m coming upon something and want to know if others have thought of it, or if there’s a generalized solution.

There are times when, usually an asset, contains a value that is saved and often needs to be applied to things which are associated with that asset. Think of it like a ‘preset’ or ‘auto-fill’ value. Here are the cases I have had, or have - it’s easier to see through examples.

**Examples:**

1. A seed asset contains a seeding rate. When a plant asset is created using that seed asset, the seeding rate is copied in as a quantity.
2. (this is my real, today problem) A field has a ‘bed\_width’. When a planting is seeding or transplanted into that field, the seeding or transplanting log gets the bed\_width quantity added.
3. A tractor asset contains ‘miles\_per\_gallon’. I add a plowing log associated with that tractor, and the plowing log gets a quantity ‘miles\_per\_gallon’. With my entered odometer readings, it can calculate the estimated energy usage.

I vaguely remember a kind of ‘calculate’ feature (wrong name I think…) which allows you to do some math and generate another value on a log or asset. Perhaps this is just a calculate type function?

Curious of any thoughts/opinions or if this is something other people experience with other examples.

---

<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:** [September 15, 2026, 10:46pm UTC](https://farmos.discourse.group/t/does-this-exist-save-values-as-presets-on-assets-to-apply-to-logs-associated-with-them/2603/2 "2026-09-15T22:46:40Z")

</div>

> [@gbathree](#):
>
> 1. A seed asset contains a seeding rate. When a plant asset is created using that seed asset, the seeding rate is copied in as a quantity.

Ideally this information would be stored on the `plant_type` taxonomy term, which is shared by both `plant` and `seed` assets.

> [@gbathree](#):
>
> 1. (this is my real, today problem) A field has a ‘bed\_width’. When a planting is seeding or transplanted into that field, the seeding or transplanting log gets the bed\_width quantity added.

Probably makes sense for this to just be some bespoke event subscriber logic in a custom module. Sounds like a convention (with some additional data model requirements) that would be well suited for a small module.

> **[Subscribe to and dispatch events](https://www.drupal.org/docs/develop/creating-modules/subscribe-to-and-dispatch-events)**
>
> Specific version(s) For Drupal versions: 10.3+, 11.0+ Event Systems Overview Event systems are used in many complex applications as a way to allow extensions to modify how the system works. An event system can be implemented in a variety of ways, but...

> [@gbathree](#):
>
> 1. A tractor asset contains ‘miles\_per\_gallon’. I add a plowing log associated with that tractor, and the plowing log gets a quantity ‘miles\_per\_gallon’. With my entered odometer readings, it can calculate the estimated energy usage.

This particular example probably makes more sense as a “computed” value than a strict `miles_per_gallon` property on the tractor asset. Instead, I would probably develop a convention with two logs:

1. tractor use, which records start/end odometer readings
2. tractor fuel tank fills, which records how much fuel was added

After collecting some data, you can calculate a crude average fuel consumption rate. This could be shown in a report or a little widget on the tractor asset itself.

> [@gbathree](#):
>
> I vaguely remember a kind of ‘calculate’ feature (wrong name I think…) which allows you to do some math and generate another value on a log or asset. Perhaps this is just a calculate type function?

Drupal has a concept of a “computed” field, which does not store a static value in the database but instead can run PHP logic to figure out a value on-the-fly (and cache it).

> **[Using computed fields in Drupal 11 and Views | kevinquillen.com](https://kevinquillen.com/using-computed-fields-drupal-11-and-views)**
>
> Every so often I run into something in Drupal that reminds me why I still enjoy working with it after all these years. Recently, while working with the Group module, I needed to display a few pieces of dynamic information: the number of members in...

(That link seems to be a good source of info… searching for “drupal computed field” is less useful because it returns info about an old contrib module, but what I’m talking about it Drupal core functionality.)

We use computed fields in farmOS for “current location” of an asset, among some other things.
