verbb / formie

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

Limit Submissions not working as expected with custom ajax form #1665

Closed KarolJurczykDS closed 6 months ago

KarolJurczykDS commented 6 months ago

Describe the bug

  1. When sending custom ajax form isWithinSubmissionsLimit method is not triggering, most likely because there is no draft/incomplete flag set in this scenario (other two checks - requireUser and scheduleForm - are working fine): https://github.com/verbb/formie/blob/craft-4/src/elements/Submission.php#L440

  2. When rendering custom ajax form isAvailable and/or it's inner methods are not available in graphql schema, so it's impossible to check if it should be rendered or not https://github.com/verbb/formie/blob/craft-4/src/elements/Form.php#L2078

Steps to reproduce

  1. FORM Limit Submissions = true Number of Submissions = X total

POST /actions/formie/submissions/submit

PAYLOAD fields[firstName]: Karol fields[lastName]: DS ... handle: testForm```

  1. In CraftCMS: /admin/graphiql

Form settings

Craft CMS version

4.5.5

Plugin version

2.0.36

Multi-site?

No

Additional context

We're using NextJS with custom formie component

engram-design commented 6 months ago

I've added handling for both of those. Note that some checks like the required user might be tricky with headless scenarios and maintaining a user session.

To get this early, run composer require verbb/formie:"dev-craft-4 as 2.0.44.1".

KarolJurczykDS commented 6 months ago

Works like a charm, thanks, can close it now

engram-design commented 6 months ago

Updated in 2.0.45