< 032020-12-04⋎05 >

farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Feature requests and bug reports: github.com/farmOS/farmOS/issuesSet by ChanServ on 2018-08-16 at 14:32
15:26mstenta[m]FYI paul121 and symbioquine the Docker `drupal:9` image that we inherit from updated to PHP 8 yesterday (with the release of Drupal 9.1). This caused some issues which broke our tests. I experimented a bit to see if I could make it work, but there are some upstream deps that need to declare their PHP 8 support. So instead I changed our Docker image so it inherits from `drupal:9.0` explicitly, and created an issue to
15:26mstenta[m]document next steps: www.drupal.org/project/farm/issues/31865
15:26mstenta[m]Apart from that, tests are still failing due to an issue in Drupal 9.1 upstream.... but it looks like they just fixed it, so hopefully there will be a patch release soon and tests will magically start passing again. :-)
15:26mstenta[m]www.drupal.org/project/drupal/issues/318
19:43mstenta[m]symbioquine: XDebug ALSO updated recently (what a month!) - not sure if you're using that at all, but if so you'll need to update some environment variables to make it work. Ping me if you need help!
19:55*skalakm[m] has joined
19:57*sent a long message: < matrix.org/_matrix/media/r0/download/mat >
19:58mstenta[m]skalakm: hmm
19:58mstenta[m]Try adding `form_set_error('test', 'hold up!');` right at the beginning of `testing_validation()`
19:59mstenta[m]Your validation is not stopping the form from being submitted... so you may not actually be seeing submitted values. If the form is reloading after submission you may be seeing the fresh (empty) values of a new form.
19:59mstenta[m]`form_set_error()` will throw a validation warning, preventing submission
20:00skalakm[m]That did it.
20:00mstenta[m]tip: install the devel module, and you can just put `dpm($form_state['values'])` instead of the echos and print_rs - and it looks pretty :-)
20:00mstenta[m]drupal.org/project/devel
20:01mstenta[m]one other small observation... `farm_form_alter()` should be named `[mymodule]_form_alter()` (where `[mymodule]` is the name of your module)
20:02mstenta[m]`farm_form_alter()` essentially means "`hook_form_alter()` provided on behalf of the `farm` module"
20:02skalakm[m]My intention was to grab every form going through. Is that not what it will do?
20:03mstenta[m]it will
20:03mstenta[m]yes, what you have works
20:03mstenta[m]it's just that it should be named based on your module
20:03mstenta[m]not `farm_*`
20:03mstenta[m]are you doing this in a custom module?
20:04skalakm[m]Yes.
20:04mstenta[m](this is a "best practice" tip...)
20:04mstenta[m]ok so if your module is `mymodule.module`
20:04mstenta[m]then the function should be named `mymodule_form_alter()`
20:04mstenta[m]if you rename it to that, it should still work for you
20:06mstenta[m]Drupal basically calls out to all modules and says "hey! any of you modules got a function named `$modulename . '_form_alter'`? ok go!"
20:06mstenta[m]so your hooks should always start with the name of your module
20:06skalakm[m]Okay, I wasn't clear on that. I thought it needed the name of the module it was altering.
20:07mstenta[m]`farm_form_alter()` works because `farm` is already a module (technically it's the install profile, but works the same as far as hooks go) - but it essentially means you're writing a hook on behalf of another module
20:07mstenta[m]ah nope! it uses the name of the module that is implementing the hook itself
20:07mstenta[m]("implementing" means providing a hook function, "invoking" means running the hook function (which is what Drupal does))
20:08skalakm[m]So if I wanted to use the more specific form it would be something like module_form_farm_log_harvest_alter?
20:09skalakm[m]mymodule_form_farm_log_harvest_alter
20:09mstenta[m]ah yea... so now that's getting into the available hooks...
20:09mstenta[m]there are two options:
20:10mstenta[m]`hook_form_alter`: api.drupal.org/api/drupal/modules%21syst
20:10mstenta[m]`hook_form_FORM_ID_alter`: api.drupal.org/api/drupal/modules%21syst
20:10mstenta[m]they both work the same... `hook_form_alter` just gives you a `$form_id` parameter to check
20:11skalakm[m]Yeah, I get that I can just user hook_form_alter, but I'm just checking if I'm understanding the setup.
20:11mstenta[m]so if you want to alter `log_form`, for instance:
20:11skalakm[m]*just use
20:11mstenta[m]`mymodule_form_log_form_alter()`
20:11mstenta[m]yea, i prefer to use `hook_form_FORM_ID_alter()` whenever possible - keeps things separated into functions nicely
20:12mstenta[m]if you need to do dynamic logic that affects multiple forms, then the more general hook is useful
20:13mstenta[m]skalakm: how's the FarmData -> farmOS stuff going?
20:14mstenta[m]I was thinking about you the other day...
20:14skalakm[m]Well Grant has started using it in class and he won an award from Gnome.
20:14mstenta[m]We're working on farmOS 2.x - and the migration capabilities are pretty awesome
20:15skalakm[m]We're still working with the Dickinson Farm to figure out what forms/customizations they want.
20:15skalakm[m]Is farmOS 2 on Drupal 8?
20:15mstenta[m]Drupal 9 in fact :-)
20:15skalakm[m]Or 9?
20:16mstenta[m]> Well Grant has started using it in class and he won an award from Gnome.
20:16mstenta[m]Cool! Do you mean with FarmData? Or farmOS?
20:17skalakm[m]He is using FarmData2 on farmOS.
20:17mstenta[m]Awesome!
20:19mstenta[m]Have you done a lot of customization on top?
20:19skalakm[m]Just the custom modules that Allen added so far.
20:19mstenta[m](I'm trying to make sure folks are aware of 2.x... and planning ahead0
20:20skalakm[m]I'll bring it up when I see them next Tuesday. How hard will it be to migrate custom modules, data, etc.?
20:20skalakm[m]And when do you think it will roll out?
20:21mstenta[m]Depends on what customizations you've made
20:21mstenta[m]We're aiming for the Spring, but that will be "beta" - might still be rough around the edges
20:21mstenta[m]We're writing automated migrations for all core farmOS data
20:22mstenta[m]So if you're not adding new fields, log types, etc, then you're covered
20:24skalakm[m]Ok. While I got you here, how would I get a list of all planting assets in the code?
20:26mstenta[m]You might try `EntityFieldQuery`
20:26mstenta[m]www.drupal.org/docs/7/creating-custom-mo
20:26mstenta[m]Or, you could do a `SELECT id FROM {asset} WHERE type='planting'` and then plug that into `farm_asset_load_multiple()`
20:27mstenta[m]`farm_asset_load_multiple()` takes an array of asset IDs
20:27skalakm[m]Any reason to not just hit the database directly?
20:28mstenta[m]It couples your code to the raw db structure, rather than using the higher level APIs like `EntityFieldQuery`
20:28mstenta[m]but that said... `EntityFieldQuery` is not in D8, so I'd say just do database queries
20:28mstenta[m]might be easier to migrate
20:29mstenta[m](have to balance "best practice" with "a lot of things are changing in D9 anyway")
20:29skalakm[m]Alright. Thanks again for the help and I'll let you know what everyone thinks about the farmos2 stuff.
20:30mstenta[m]Cool. We are beginning to document things here: 2x.farmOS.org
20:30mstenta[m]we gotta get Github to fix that SSL cert :-/
20:30mstenta[m](hosted on github pages, but ssl is broken for some reason)
20:30skalakm[m]Good luck with that. ttyl

< 032020-12-04⋏05 >