| [06:04:18] | * farmBOT has joined #farmos |
| [11:59:58] | <skalakm[m]> | I'm playing around with customizing a module, but it's not having any effect. I changed the file www/profiles/farm/modules/farm/farm_log/farm_log_harvest (specifically the quantity description about the potatoes) but it does not show up when I access the log harvest form on my website. Is there some cache I have to clear or am I doing something more fundamentally wrong? |
| [12:01:26] | <mstenta[m]> | Hi skalakm - yes couple of thoughts: |
| [12:02:09] | <mstenta[m]> | - You should avoid changing core farmOS files if possible - otherwise you need to make sure to maintain those changes across farmOS updates - which are typically done by deleting everything and replacing it with the new version |
| [12:02:49] | <mstenta[m]> | - The `farm_log_harvest` module (and many others) are managed as "Features" modules (https://drupal.org/project/features) - if you make a change in them, you may need to "Revert" them in the Features admin `/admin/structure/features` to get the changes |
| [12:03:42] | <mstenta[m]> | - Not sure what you want to alter exactly, but keep in mind that harvest logs are meant to be used for more than just plants. Animals and other asset types can also have harvests associated with them. |
| [12:05:27] | <skalakm[m]> | The recreate worked. Thanks. I'm not really altering with a particular goal, I'm just poking around at this point. |
| [12:06:07] | <mstenta[m]> | Cool! |
| [12:06:39] | <skalakm[m]> | Bigger picture, if I wanted to add some data sanity checks eg you can't harvest something that hasn't been planted, where should that go? |
| [12:06:54] | <mstenta[m]> | FYI "Recreate" will generate a new module that you can download and replace the old one (if you make changes through the UI for instance) - but "Revert" will revert to whatever is defined in code |
| [12:07:35] | <mstenta[m]> | Hmm well you have to think about all the possible ways that someone can create a harvest log... |
| [12:08:14] | <mstenta[m]> | ACTION sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/CldAyBSELlxqGbBP... > |
| [12:08:53] | <mstenta[m]> | (5. CSV imports) |
| [12:09:05] | <mstenta[m]> | There isn't a single place that will cover all of those, unfortunately |
| [12:09:42] | <mstenta[m]> | But if you want to just focus on the Harvest edit form, you could add a validation function to the form that runs when it gets submitted, and check the referenced assets |
| [12:10:42] | <skalakm[m]> | Where would that validation function go? |
| [12:11:17] | <mstenta[m]> | In a custom module |
| [12:12:32] | <mstenta[m]> | You would need two functions: your validation function (you can look for functions ending in `_form_validate(` for examples, and you would need to implement `hook_form_alter()` to alter the form you want (id == `log_form`) |
| [12:12:51] | <mstenta[m]> | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func... |
| [12:16:15] | <mstenta[m]> | This might help: https://befused.com/drupal/form-validation |
| [12:16:25] | <mstenta[m]> | None of this is farmOS-specific - just Drupal stuff |
| [12:17:29] | <skalakm[m]> | Ok, thanks for the pointers. I'll give it a try this afternoon. |