Search.../

submit( )

Deprecated: Submits an RSVP form and adds the new guests to the event's guest list.

Description

Deprecation note: The submit() function of the RsvpForm object is being deprecated. Use the createRsvp() function of the Rsvp object instead.

The submit() function returns a Promise that resolves to an RsvpResponse when the guests in the specified form values have been added to the event's guest list.

The list of FormValue objects you pass to submit() must include a form value for the rsvpStatus. Which statuses you can return depends on the rsvpStatusOptions returned from the getRsvpData() function as follows:

  • "YES_AND_NO": Send an rsvpStatus of "YES" or "NO".
  • "YES_ONLY": Send an rsvpStatus of "YES".
  • "OPEN_RSVP_WAITLIST": Send an rsvpStatus of "WAITING" to add a guest to the waitlist.

When submitting an RSVP form with rsvpStatus of "WAITING" or "NO", the list of FormValue objects should only contain items for "firstName", "lastName", "email", and "rsvpStatus". No other fields should be passed.

When a form contains an input for adding more guests to an RSVP, format the guest names for submission in an array where each element is the full name of a guest.

When a form contains an address, the way you format the address information for submission depends on what type of input elements you use to gather that information as follows:

  • If the address is input using a Wix address input element, no special formatting is needed.
  • If the address is input using another type of input element, such as a text input, format the input's value in an array.
  • If the address is input using a number of input elements, each for a different part of the address, format the input values as elements in an array.

Note: To work with the Wix Events API, you need to publish your site.

Syntax

function submit(formValues: Array<FormValue>): Promise<RsvpResponse>

submit Parameters

NAME
TYPE
DESCRIPTION
formValues
Array<FormValue>

List of field names and values for an RSVP form.

Returns

Fulfilled - Information about the RSVP that was created. Rejected - Error information. One of:

  • SubmissionError
  • FieldValidationError
  • ValueValidationError

Return Type:

Promise<RsvpResponse>
NAME
TYPE
DESCRIPTION
id
string

RSVP ID

anonymized
boolean

Indicates whether the guest's personal information has been deleted or not.

contactId
string

Contact ID of the guest who submitted the RSVP form.

createdDate
Date

Date when the RSVP was submitted.

email
string

Email address to the guest who submitted the RSVP form.

eventId
string

ID of the event the RSVP is for.

firstName
string

First name of the guest who submitted the RSVP form.

lastName
string

Last name of the guest who submitted the RSVP form.

guests
Array<Guest>

All of the guests included in the RSVP.

rsvpForm
RsvpForm

A representation of the RSVP form that was submitted.

memberId
string

Member ID of the guest who submitted the RSVP form if the guest is a site member.

updatedDate
Date

Date when RSVP was last modified.

status
string

RSVP status.

totalGuests
number

Total number of guests included in the RSVP.

Was this helpful?

Submit an RSVP form

Copy Code
1import wixEventsFrontend from 'wix-events-frontend';
2
3// ...
4
5const eventId = // Get the event ID
6const form = wixEventsFrontend.createEventRsvpForm(eventId);
7
8// ...
9
10let formValues = // get form values
11
12form.submit(formValues)
13 .then((response) => {
14 let totalGuests = response.totalGuests; // 2
15 let firstGuestName = response.guests[0].fullName; // Jane Doe
16 })
17 .catch((error) => {
18 let message = error.message; // "Guest limit exceeded: only 1 person can RSVP"
19 let errorType = error.errorType; // "GUEST_LIMIT_REACHED"
20 });
21
22/*
23 * Success response:
24 * {
25 * "anonymized": false,
26 * "contactId": "f1b9e9b3-5acb-4f15-ada8-e31a34a376ec",
27 * "createdDate": "2019-09-02T12:29:34.944Z",
28 * "email": "john.doe@somedomain.com",
29 * "eventId": "caad2acf-5c64-4eab-97f8-6710feac9151",
30 * "firstName": "John",
31 * "lastName": "Doe",
32 * "guests": [
33 * {
34 * "index": 0,
35 * "fullName": "John Doe",
36 * "id": 1
37 * }
38 * ],
39 * "id": "c71fc4d1-661e-473c-8b8c-74d97cf91b22",
40 * "memberId": "",
41 * "updatedDate": "2019-09-02T12:29:34.944Z",
42 * "rsvpForm": {
43 * "inputValues": [
44 * {
45 * "inputName": "firstName",
46 * "value": "John",
47 * "values": [],
48 * },
49 *
50 * ...
51 *
52 * {
53 * inputName: "custom",
54 * value: "",
55 * values: ["Gluten free", "Vegetarian"],
56 * }
57 * ]
58 * },
59 * "status": "YES"
60 * "totalGuests": 1
61 * }
62 */
Create and submit an RSVP form

Copy Code
1import wixEventsFrontend from 'wix-events-frontend';
2import wixData from 'wix-data';
3
4$w.onReady(function () {
5 let form;
6
7 // Run a query that returns only one event. Add
8 // additional filtering to the query if necessary.
9 wixData.query("Events/Events")
10 .eq("title", "My Event")
11 .find()
12 .then((results) => {
13 if (results.items.length > 0) {
14 form = wixEventsFrontend.createEventRsvpForm(results.items[0]._id);
15 } else {
16 console.log("Could not find event");
17 }
18 });
19
20 $w("#submit").onClick(() => {
21 const formValues = getFormValues();
22
23 form.submit(formValues)
24 .then((result) => {
25 console.log("RSVP form submitted.")
26 })
27 .catch((error) => {
28 console.log(`Error message: ${error.message}`);
29 if (error.fields) {
30 console.log(`Incorrect fields: ${error.fields}`);
31 }
32 });
33 });
34});
35
36function getFormValues() {
37 return [
38 {"name": "rsvpStatus", "value": "YES"},
39 {"name": "firstName", "value": $w("#firstName").value},
40 {"name": "lastName", "value": $w("#lastName").value},
41 {"name": "email", "value": $w("#email").value},
42 {"name": "custom", "value": $w("#foodAllergies").value},
43
44 // When a form contains an address, the way you format the
45 // address information for submission depends on what type
46 // of input elements you use to gather that information.
47
48 // Wix address input element.
49 {"name": "address", "value": $w("#address").value},
50
51 // Single element which is not an address
52 // input element, such as a text input.
53 {"name": "address", "value": [$w("#address").value]},
54
55 // Multiple elements for the
56 // various parts of an address.
57 {
58 "name": "address",
59 "value": [
60 $w("#street").value,
61 $w("#city").value,
62 $w("#state").value,
63 $w("#country").value,
64 $w("#postalCode").value
65 ]
66 },
67
68 // When a form contains an input for adding more guests to an
69 // RSVP, format the guest names for submission in an array
70 // where each element is the full name of a guest.
71 {"name": "additionalGuests", "value": $w('#additionalGuests').value},
72 {
73 "name": "guestNames",
74 "value": [
75 `${$w("#guest1FirstName").value} ${$w("#guest1LastName").value}`,
76 `${$w("#guest2FirstName").value} ${$w("#guest2LastName").value}`,
77 ]
78 }
79 ];
80}