verbb / formie

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

Element Integration - Entry field issue #1945

Closed svondervoort closed 3 months ago

svondervoort commented 3 months ago

Describe the bug

I'm trying to map a text input to an entry field in an element integration - entry but I get the error:

Failed to trigger integration: ["Element integration failed for submission “1812”. Error: Invalid numeric value: 2024\/2025 \/******\/******\/******\/******\/vendor\/craftcms\/cms\/src\/helpers\/Db.php:599"].

I'm not sure if it is possible, but I would like to be able to automatically create (if not existant) or select (if already existant) the entry in the entry field. FeedMe does the same.

Steps to reproduce

  1. Create 2 entry sections (one for the form submissions and one for the entry field that will be mapped with the form)
  2. Create an entry field with the previously created section
  3. Create an element integration in Formie linked to the previously created section
  4. Create a form with a text-field
  5. Map the text-field to the entry

Form settings

Craft CMS version

4.10.2

Plugin version

2.1.19

Multi-site?

Yes

Additional context

No response

svondervoort commented 3 months ago

I did some more testing, and looks like it is looking for a specific element/entry ID to match with. So the value i'm sending obviously doesn't match since it doesn't check for title and/or id.

engram-design commented 3 months ago

So I imagine you might have the ID for an entry in your Single-Line Text field, correct? That might be 2024 which you would like to match an entry element in an Entries field.

That should be possible, but there is a bug with that. Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.1.19".

However, I see the error shows Invalid numeric value: 2024\/2025 - what are you actually entering in the Single-Line Text field in Formie?

svondervoort commented 3 months ago

So as I understand it works on a existing ID, but it does not work on a Title of an existing Entry. I'm not sure if its possible, but it would be great if the mapped field would also create an entry if it does not exist already. And also for it to be matched on title instead of just an ID.

engram-design commented 3 months ago

Gotcha, so yep the value of the entries field will need to be the ID, either a single ID or a collection of them.

I know this was built into Feed Me a while ago (being able to pick what to match on), but that's not something that's built into Formie's mapping at the moment. It's probably something we'll get to one day, but it's quite a complication at the moment, and a whole new UI we'd need to implement (which is on the roadmap, but a way off yet).

Similarly, Formie won't create the element for an element field. It's also probably not something we're planning on supporting due to its overcomplexities. For example:

I'd say the best place for all this logic would be in an event - and that's probably not going to change anytime soon. It's absolutely possible to achieve what you want with the beforeSendPayload or afterSendPayload events.

svondervoort commented 3 months ago

I totally understand. Would be great to have it in a future version sometimes. Thanks for taking the time. In our case we can just create the entry in advance and prefill the field with the correct ID.

FeedMe actually can create an entry if the matching "type" is title instead of an ID since title is a required field within the entry. I guess FeedMe knows in which section the entry has to be created since the field has certain sections checked (see screenshot).

Screenshot 2024-06-20 at 12 00 59

engram-design commented 3 months ago

Indeed, in Feed Me you select the section and type and the data you are providing (ID, slug, title, etc). We'd have to introduce a similar UI in Formie to handle that. (FYI, I wrote Feed Me, and am aware of this sort of setup and that it can get complicated quickly!)