verbb / formie

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

FieldSelect for multiple fields #1691

Open gglnx opened 9 months ago

gglnx commented 9 months ago

What are you trying to do?

I'm trying to build an integration, which only applies to a selected set of fields. But because there is no mapping target, I can't use IntegrationFieldMapping and FieldSelect only allows selecting one field (and its reset value is hard-coded to Always opt-in).

What's your proposed solution?

The basic version would be FieldSelectMultiple which renders all fields as FieldSelect but as checkmark group. A deluxe version would be based on an editable table which allows adding, deleting and reordering. But for my use case the checkbox group is sufficient.

Additional context

This could be used for webhook integrations too to select which fields to send to the webhook endpoint.

engram-design commented 9 months ago

If you don't require any mapping, then you can forego the mapping mechanism most integrations use. The webhook integrations you mention do this with generatePayloadValues which just grabs all the form and submission data it can, and forwards that on.

We can certainly look at providing a UI for which attributes/fields to pick to send in the request, that's fine. Otherwise, for your integration, it's a matter of grabbing that content yourself.

public function sendPayload(Submission $submission): bool
{
    $payload = [
        'title' => $submission->title,
        'fieldOne' => $submission->getFieldValue('fieldOne'),
    ];

    // ...
gglnx commented 7 months ago

I need some kind of mapping.

My plan is to write an integration, that allows the form submitter to save the fields values into local storage (after checking a checkbox), so the next time the form will be pre-filled. But not all fields should be saved and pre-filled. This also should work across different forms.

This could be well out of scope, but maybe I try to ask if a general solution would be feasible, before I start to development a custom Vue component myself.

engram-design commented 7 months ago

We have plans to tackle this properly with a custom UI component, but nothing has been started yet, and won't be for a little while yet (end of year). We would plan to support picking multiple fields, but probably more in the style of the variable-picker and calculations field, as people will want to do different things with fields (concatenate, modify, etc).

gglnx commented 7 months ago

Thanks for the information. I'll build for now something myself :)

engram-design commented 7 months ago

I'll keep this open to track!