Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms #17

Merged
merged 6 commits into from
Oct 28, 2024
Merged

Forms #17

merged 6 commits into from
Oct 28, 2024

Conversation

rockwellll
Copy link
Collaborator

This PR adjusts completed forms to dispatch a form:completed event when attempting to mount an already completed form when ifCompleted Is set to true when calling Form.mount.

Rationale

Developers don't want to worry about removing the element of an already completed form. This PR lifts the burden of the developer and lets the library manage the removal of already completed forms.

Payload adjustments

The payload for form:completed is also updated, it now includes a completedAt attribute that lets the developer know when the form was completed, this allows developers to show the form again if they have some specific expiry timestamp for the form submission. In addition, it updates the readme to highlight the new payload.

Hellotext.on('form:completed', (form) => {
  console.log(form) // An object from FormData
})

{
  state: 'completed',
  completedAt: 1730114734999, // Timestamp when the form was completed
  id: "xxxxx", // Id of the form that has been completed
  data: {
    first_name: "Billy",
    last_name: "Butcher",
    email: "theboys@hellotext.com",
    phone: "+1234567890",
    property_by_id[xxxxx]: "value"
  }
}

@rockwellll rockwellll merged commit 99ad68a into main Oct 28, 2024
2 checks passed
@rockwellll rockwellll deleted the forms branch October 28, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant