IRC logs for #farmOS, 2021-04-06 (GMT)

2021-04-05
2021-04-07
TimeNickMessage
[11:54:52]<skipper_is[m]>...How do you use a taxonomy as an autofill?
[11:55:27]<mstenta[m]>are you trying to add an "autocomplete" text field to a form?
[11:55:56]<mstenta[m]>maybe something like this?
[11:55:57]<mstenta[m]>https://github.com/farmOS/farmOS/blob/92f854b9be271e06f2e005f14d64653eb4...
[11:58:28]<skipper_is[m]>Yea, and that seems to correlate to the taxonomy of farm_crop, but when i do the same for my own taxonomy (with some values already in it) it says it cannot find the taxonomy
[11:59:02]<skipper_is[m]>"Taxonomy field quick_medical not found."
[11:59:47]<skipper_is[m]>(Also, the autocomplete for vets, in medical logs, is that autocomplete usable in forms? Is it also from a taxonomy?)
[12:02:39]<skipper_is[m]>ACTION < https://matrix.org/_matrix/media/r0/download/matrix.org/TJKtXzXdGhIWfAIl... >
[12:14:54]<mstenta[m]>ah... so `taxonomy/autocomplete/field_farm_crop` essentially works by leveraging the fact that there is a field called `field_farm_crop` (for referencing terms in the vocabulary)
[12:15:06]<mstenta[m]>do you have a field set up? if so make sure you use that field's name in the autocomplete path
[12:16:17]<skipper_is[m]>I have not, I have a taxonomy with a bunch of medicines as terms
[12:17:08]<mstenta[m]>ok - so if you add a term reference field to a log type, then you can reference that field's name in the autocomplete path and it should work
[12:17:17]<mstenta[m]>the field is where you configure "this field references terms in this vocabulary"
[12:17:19]<mstenta[m]>so it makes that connection
[12:17:41]<mstenta[m]>we just went with that approach because it was already set up and met our needs... i don't know if Drupal core provides a more general term reference autocomplete path
[12:17:51]<mstenta[m]>but the cool thing is: you can also just make your own routes for autocomplete paths
[12:17:55]<mstenta[m]>if you need something more custom
[12:18:08]<skipper_is[m]>so field_farm_vets should work as an autocomplete?
[12:18:14]<skipper_is[m]>(it doesn't seem to)
[12:18:41]<mstenta[m]>https://github.com/farmOS/farmOS/blob/c5c15043cf30275fa1bdadf8e39a9393ff...
[12:19:04]<mstenta[m]>if you have a field called `field_farm_vets` which is a term reference field to the vocabulary you want... it should
[12:19:20]<skipper_is[m]>the log_medical has a field called field_farm_vets
[12:19:25]<skipper_is[m]>By default
[12:20:30]<mstenta[m]>oh, but that's not a term reference field
[12:20:36]<mstenta[m]>(`field_farm_vet` correct?)
[12:20:59]<mstenta[m]>that's just a string field
[12:21:09]<mstenta[m]>we provide an autocomplete for that as well, however :-)
[12:21:17]<mstenta[m]>it's just not a term autocomplete...
[12:21:24]<mstenta[m]>and in fact, that uses the custom module i just linked to above
[12:22:07]<mstenta[m]>the `farm_fields_autocomplete` module in farmOS 1.x provides auto-complete for all text fields on logs... by searching the database for previously entered values
[12:22:13]<mstenta[m]>maybe that's what you want?
[12:23:08]<skipper_is[m]>So can I plug field_farm_vet into that?
[12:23:38]<mstenta[m]>possibly! just need to figure out the right path to use...
[12:24:27]<mstenta[m]>`farm/fields/autocomplete/[entity type]/[bundle]/[field name]`
[12:24:34]<mstenta[m]>so try this:
[12:25:08]<mstenta[m]>`'#autocomplete_path' => 'farm/fields/autocomplete/log/farm_medical/field_farm_vet',`
[12:25:37]<skipper_is[m]>oh nice one, cheers
[12:28:31]<skipper_is[m]>An I guess likewise I can use farm/fields/autocomplete/log/farm_medical/name to get an autocomplete of medical log names?
[12:28:50]<mstenta[m]>should work!
[12:28:53]<skipper_is[m]>Or can i just do farm/fields/autocomplete/log/name?
[12:28:58]<skipper_is[m]>And get all the logs?
[12:29:04]<mstenta[m]>no - needs the bundle too
[12:29:32]<skipper_is[m]>Ah ok, some of them have a +, can I choose multiple bundles (the assets/group one is assets+group)
[12:29:54]<mstenta[m]>i don't remember if there's support for that or not in `farm_fields_autocomplete.module`
[12:30:02]<mstenta[m]>you could probably see how it works pretty easily
[12:30:14]<mstenta[m]>gotta sign off... taking over with the kids :-)
[12:30:15]<mstenta[m]>good luck!
[12:30:27]<skipper_is[m]>Diolch yn fawr!
[13:26:35]<skipper_is[m]>Is there an autocomplete for quantity labels? There is for quantity units, and in the log forms there is one for quantity, but can we hook in?
[13:27:26]<mstenta[m]>Good question
[13:27:40]<mstenta[m]>The same URL as before might work
[13:28:13]<mstenta[m]>The entity type would be field_collection
[13:28:26]<mstenta[m]>Bundle is field_farm_quantity
[13:28:40]<mstenta[m]>Field is field_farm_quantity_label
[13:28:42]<mstenta[m]>I think
[13:29:55]<skipper_is[m]>farm/fields/autocomplete/log/field_collection/field_farm_quantity/field_farm_quantity_label
[13:30:08]<skipper_is[m]>Goodness me that is a good length
[13:30:31]<mstenta[m]>Minus the log piece
[13:30:50]<mstenta[m]>Haha yes... The field collections are messy like that
[13:31:55]<mstenta[m]>FWIW it would be /farm/fields/quantity/standard/label in farmOS 2.x
[13:32:18]<skipper_is[m]>At one point I'll get farmOS2 installed and start finding the weird bugs
[13:33:02]<mstenta[m]>Hahaha
[13:33:34]<mstenta[m]>Also FWIW farmOS 2.x doesn't have a farm_fields_autocomplete module yet
[13:34:38]<mstenta[m]>@paul121 did some research into an alternative module we might be able to use
[13:35:30]<skipper_is[m]>`farm/fields/autocomplete/field_collection/field_farm_quantity/field_farm_quantity_label` is returning [] when I open the URL, suggesting it is working, but doesn't seem to return any values when I actually use it, which is a shame
[13:36:57]<skipper_is[m]>field_collection_item!
[13:52:37]<mstenta[m]>oh yesss
[16:05:37]<skipper_is[m]>If creating notes programatically, how can I get a newline in?
[16:06:39]<skipper_is[m]>I tried <br> and \n
[16:06:45]<skipper_is[m]>oh < b r >
[16:06:49]<skipper_is[m]>didn't let me type it
[16:30:28]<skipper_is[m]>"/n" instead of '/nl'
[16:30:37]<skipper_is[m]>*'/n'