Search...
createEventRsvpForm( )
Deprecated: Creates a new RSVP form for the specified event.
Description
Deprecation note: The createEventRsvpForm()
function is being deprecated. Use
the getForm()
function instead.
Use the createEventRsvpForm()
function to retrieve the information
you need to create a custom RSVP form
for a specified event and to submit the form data to register guests for the event.
Retrieve event IDs to specify an event from the Events/Events collection.
Note: To work with the Wix Events API, you need to publish your site.
Syntax
function createEventRsvpForm(eventId: string): RsvpForm
createEventRsvpForm Parameters
NAME
TYPE
DESCRIPTION
eventId
string
ID of the event to create an RSVP form for.
Was this helpful?
Create an RSVP form
Copy Code
1import wixEventsFrontend from 'wix-events-frontend';23// ...45const eventId = // get an event ID67const eventRsvpForm = wixEventsFrontend.createEventRsvpForm(eventId);
Create and submit an RSVP form
Copy Code
1import wixEventsFrontend from 'wix-events-frontend';2import wixData from 'wix-data';34$w.onReady(function () {5 let form;67 // Run a query that returns only one event. Add8 // 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 });1920 $w("#submit").onClick(() => {21 const formValues = getFormValues();2223 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});3536function 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},4344 // When a form contains an address, the way you format the45 // address information for submission depends on what type46 // of input elements you use to gather that information.4748 // Wix address input element.49 {"name": "address", "value": $w("#address").value},5051 // Single element which is not an address52 // input element, such as a text input.53 {"name": "address", "value": [$w("#address").value]},5455 // Multiple elements for the56 // 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").value65 ]66 },6768 // When a form contains an input for adding more guests to an69 // RSVP, format the guest names for submission in an array70 // 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}