IRC logs for #farmOS, 2022-03-03 (GMT)

2022-03-02
2022-03-04
TimeNickMessage
[04:00:50]* qoyyuum[m] has quit (Quit: You have been kicked for being idle)
[04:00:50]* sgoodall[m] has quit (Quit: You have been kicked for being idle)
[08:10:38]<jgaehring[m]>interesting report:
[08:10:38]<jgaehring[m]>https://www.agriculture.com/news/business/poor-or-no-internet-for-3-in-1...
[11:21:05]* ZaneBelkhayat[m] has joined #farmos
[11:25:53]<ZaneBelkhayat[m]>Hi all, I'm new to farmOS and working on the same project as Marcos Carballal, could anyone point me to documentation on 'createAsset' as a part of Quick Forms?
[11:27:34]<mstenta[m]>Hi Zane Belkhayat - this might help: https://farmos.org/development/module/quick/
[11:28:03]<mstenta[m]>Specifically the "Traits and helper methods" section
[11:28:31]<mstenta[m]>Note that these are just wrappers around Drupal core Entity API methods - so you may be able to get more detailed docs for those....
[11:28:47]<mstenta[m]>https://www.drupal.org/docs/drupal-apis/entity-api/working-with-the-enti...
[11:29:03]<mstenta[m]>We just provide helpers to make common things easier within quick forms
[11:29:27]<mstenta[m]>But you can also work with the Entity API directly for full power :-)
[11:30:11]<mstenta[m]>Here are the traits that farmOS core provides, if you want to see what they are doing specifically: https://github.com/farmOS/farmOS/tree/2.x/modules/core/quick/src/Traits
[11:30:40]<mstenta[m]>eg, the `createAsset()` code specifically: https://github.com/farmOS/farmOS/blob/7014bdf9530ac59f2ff1fc7daef234a51b...
[11:31:51]<ZaneBelkhayat[m]>Ahhh, thank you this is the info I was looking for!
[11:31:57]<mstenta[m]>it's pretty simple... it basically just passes `$values` directly into `Asset::create()` - but it also trims the title to 255 chars, links the asset to the quick form that created it automatically, and displays a message to the user with a link to the new asset
[11:32:14]<mstenta[m]>so if you don't want any of those things, you can bypass `createAsset()` and roll your own
[11:45:33]<ZaneBelkhayat[m]>Another quick question, what permissions are needed for creating an asset?
[11:46:23]<mstenta[m]>Each asset type will have a permission `create [type] asset`
[11:46:42]<mstenta[m]>eg: `create plant asset`
[11:53:09]<mstenta[m]>FYI @room the farmOS weekly dev call starts in ~8 minutes here: https://meet.jit.si/farmos-dev
[11:53:27]<mstenta[m]>All are welcome!
[11:56:35]<mstenta[m]>Zane Belkhayat: if you want to hop in and ask any questions about quick forms etc feel free! or just to listen in...
[11:56:44]<mstenta[m]>Marcos Carballal too :-)
[11:57:46]<MarcosCarballal[>Sure, happy to join
[12:07:38]<symbioquine[m]>I think I'm going to miss the call today... 🥺
[13:00:31]<mstenta[m]>@room farmOS 2.0.0-beta3 has been released! 🎉 https://github.com/mstenta/farmOS/releases/tag/2.0.0-beta3
[15:53:01]<ZaneBelkhayat[m]>So I've been wracking my brain about this all day and can't seem to figure out how to record a field through quick forms
[15:59:09]<mstenta[m]>Hi Zane Belkhayat what are you trying to do?
[16:08:44]<ZaneBelkhayat[m]>I'm trying to record a simple text field, in the asset created by a quick form, but even though the field shows up on the form, it doesn't get recorded to the created asset
[16:09:31]<mstenta[m]>can you share your submit method code?
[16:09:55]<mstenta[m]>is it a custom field you've added to the asset type? or one of the ones that comes with farmOS?
[16:10:25]<ZaneBelkhayat[m]>Custom field
[16:11:25]<mstenta[m]>are you using `createAsset()`? can you share that chunk of code so i can see it?
[16:12:00]<ZaneBelkhayat[m]>$this->createAsset([
[16:12:01]<ZaneBelkhayat[m]> 'name' => $name,
[16:12:01]<ZaneBelkhayat[m]> 'type' => 'producer'
[16:12:01]<ZaneBelkhayat[m]> ]);
[16:12:43]<ZaneBelkhayat[m]>Oh shoot hold on haha I edited that recently let me get back to you
[16:12:54]<mstenta[m]>if it's a simple single-value text field that you've added, you should be able to just do:... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/b432bfb32b...)
[16:13:27]<mstenta[m]>(that assumes that the custom field you've added to the asset is called `myfield`, and the field in your quick form is called `form_field_name`)
[16:14:34]<ZaneBelkhayat[m]>Yeah I got it working immediately, thank you!
[16:14:46]<mstenta[m]>Great!