verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 72 forks source link

Subset of entries for selection in drop down #1778

Open jishi opened 6 months ago

jishi commented 6 months ago

What are you trying to do?

I'm trying to make a drop down field that is populated from a channel, but I would like to limit it based of some field existance/value on the entries, and not the full channel list. I haven't found a way to do that.

What's your proposed solution?

I'm not sure what the best solution is here. Allowing one to write a query for selection might not be very user friendly, but powerful.

Also, of there is some filtering possible as part of rendering, that might be fine too, then adding some metadat/attributes to the field could be the basis of that filtering, however I haven't found any documentation supporting that.

Additional context

My client has a channel that is filled with stallions. They want to have a form where they can select amongst the stallions, but the available selections is a subset of all stallions.

engram-design commented 6 months ago

There's a user guide on this which might be helpful. Basically covers how to modify the element query of an Entries element field to change what elements to render.

As for making this configurable in the field settings, that's an interesting idea. We'd have to make it semi-client-friendly, ideally with some form of autocomplete. I'd say that's a little further down the line as a feature request, but an interesting idea nonetheless.

jishi commented 6 months ago

There's a user guide on this which might be helpful. Basically covers how to modify the element query of an Entries element field to change what elements to render.

As for making this configurable in the field settings, that's an interesting idea. We'd have to make it semi-client-friendly, ideally with some form of autocomplete. I'd say that's a little further down the line as a feature request, but an interesting idea nonetheless.

This was great info, really clarified how to achieve what I wanted. Now I only need to figure out how to also adapt the label source, I can only select a single field from an entry (I want to combine it as TITLE (ANOTHER_FIELD)). I guess with a custom rendering template I could override the label, but having a similar template setup as exist for the email templates would have been nice.

also, I actually don't need to override template to adjust my query, I can find the field before rendering the form and adjust the query before which is really neat.

engram-design commented 6 months ago

So at the moment, you can't alter the label used for the option, that's the title (or whatever you set it to in the field settings), but it can't be a dynamic value. Maybe that's a nice feature request we'll look at adding (essentially allowing a variable-picker for the field setting, than just a dropdown).

You'll have to override the template to get that working as you require I'm afraid, sorry!