getRsvpData( )
Deprecated: Gets information about the event's RSVP form and status.
Description
Deprecation note: The getRsvpData
function of the RsvpForm
object is being
deprecated. Use the formData
property of
the Form
object instead.
The getRsvpData()
function returns a Promise that resolves to an
RsvpData
object containing all the information you need to create
a custom RSVP form for the specified event.
This information includes:
- The event's registration status, such as whether registration is open, closed, or guests will be placed on a waitlist.
- Which statuses guests can RSVP with, such as yes, no, or to be added to the waitlist.
- Information about the RSVP form's fields, such as their names, descriptive labels, and whether they are required.
Note: To work with the Wix Events API, you need to publish your site.
Syntax
function getRsvpData(): Promise<RsvpData>
getRsvpData Parameters
This function does not take any parameters.
Returns
Fulfilled - Information about the RSVP form's input fields and status options.
Return Type:
NAME
TYPE
DESCRIPTION
Information about the input fields needed to create an RSVP form.
Allowed RSVP statuses for an event. One of:
"YES_AND_NO"
: Guests can RSVP for the event with a "Yes" or "No"."YES_ONLY"
: Guests can only RSVP for the event with a "Yes"."WAITING"
: The guest limit has been reached, but there is an open waitlist.
Event registration status. One of:
"OPEN_RSVP"
: Registration is open and guest limit has not been reached."OPEN_RSVP_WAITLIST"
: Registration is open, guest limit has been reached, and additional registering guests are added to the waitlist."CLOSED"
: Registration is closed because the guest limit has been reached."CLOSED_MANUALLY"
: Registration was closed manually.
Was this helpful?
1import wixEventsFrontend from 'wix-events-frontend';23// ...45const eventId = // Get the event ID6const form = wixEventsFrontend.createEventRsvpForm(eventId)78form.getRsvpData()9 .then((rsvpData) => {10 let fields = rsvpData.rsvpFormInputs;11 let firstFieldName = fields[0].name;12 let statusOptions = rsvpData.rsvpStatusOptions;13 let registrationStatus = rsvpData.registrationStatus;14 });1516/* rsvpData:17 *18 * {19 * "rsvpStatusOptions": "YES_AND_NO,20 * "registrationStatus": "OPEN_RSVP",21 * "rsvpFormInputs": [22 * {23 * "_id": "37a5789b-27d1-43a3-703b-a93dedad5b01",24 * "additionalLabels": [],25 * "array": false,26 * "controlType": "NAME",27 * "label": "First Name",28 * "required": true,29 * "maxLength": 50,30 * "name": "firstName",31 * "options": []32 * },33 *34 * ...35 *36 * {37 * "_id": "27d5789b-137a-43ed-a33d-a9703bad5b01",38 * "additionalLabels": [39 * {40 * "name": "one",41 * "label": "I'm bringing a plus one"42 * },43 * {44 * "name": "multiple",45 * "label": "Additional Guests"46 * }47 * ],48 * "array": false,49 * "controlType": "GUEST_CONTROL",50 * "label": "I'm bringing a plus one",51 * "required": true,52 * "maxLength": 0,53 * "name": "additionalGuests",54 * "options": [55 * "0",56 * "1"57 * ]58 * }59 * ]60 * }61 */
This example assumes that a form is built with input elements, where the element
IDs match the field names retrieved from the getRsvpData()
function.
1import wixEventsFrontend from 'wix-events-frontend';2import wixData from 'wix-data';34$w.onReady(function () {5 let form;6 let rsvpData;78 // Run a query that returns only one event. Add9 // additional filtering to the query if necessary.10 wixData.query("Events/Events")11 .eq("title", "My Event")12 .find()13 .then((results) => {14 if (results.items.length > 0) {15 form = wixEventsFrontend.createEventRsvpForm(results.items[0]._id);16 form.getRsvpData()17 .then((response) => {18 rsvpData = response;19 });20 } else {21 console.log("Could not find event");22 }23 });2425 $w('#submit').onClick(() => {26 let formValues = getFormValues();2728 form.submit(formValues)29 .then((result) => {30 console.log("RSVP form submitted.")31 })32 .catch((error) => {33 console.log(`Error message: ${error.message}`);34 if (error.fields) {35 console.log(`Incorrect fields: ${error.fields}`);36 }37 });38 });39});4041function getFormValues() {42 const formValues = [{"name": "rsvpStatus", "value": "YES"}];4344 rsvpData.rsvpFormInputs.forEach((item) => {45 formValues.push(46 {47 "name": [item.name],48 "value": $w(`#${item.name}`).value49 }50 );51 });5253 // When the form contains an address or additional54 // guests, add code to add those values to formValues.5556 return formValues;57}