Hi, I’m trying to get the custom Registration Form to work but I can’t figure out what I’m doing wrong with the validation.
The eventId is a global variable and the registration form details is being retrieved correctly but when I try to validate the values entered in to form I’m getting the error TypeError: registrationFields.validate is not a function
Can anyone see what I’m doing wrong?
export function makeBooking_click ( event ) {
const formValues = getFormValues ();
console . log ( formValues );
wixEvents . getForm ( eventId )
. then ( ( result ) => {
registrationFields = result . formData ;
}
registrationFields . validate ( formValues )
. then ( ( response ) => {
console . log ( ‘form is good’ );
// handle case where form is valid
} )
. catch ( ( error ) => {
console . log ( error );
// handle case where form is not valid
let message = error . message ; // “Following fields have invalid IDs: nonExistent1, nonExistent2”
let fields = error . fields ; // [“nonExistent1”, “nonExistent2”]
});
}
function getFormValues ( ) {
let returnValues = [
{ “name” : “rsvpStatus” , “value” : “YES” },
{ “name” : “firstName” , “value” : $w ( “#firstName” ). value },
{ “name” : “lastName” , “value” : $w ( “#lastName” ). value },
{ “name” : “email” , “value” : $w ( “#emailAddress” ). value },
{ “name” : “boatName” , “value” : $w ( ‘#boatName’ ). value },
{ “name” : “custom” , “value” : $w ( “#otherInfo” ). value }
];
if ( $w ( ‘#plusOneSelection’ ). checked ) {
returnValues . splice ( returnValues . length , 0 ,
{ “name” : “guestFirstName” , “value” : $w ( ‘#guestFirstName’ ). value },
{ “name” : “guestLastname” , “value” : $w ( ‘#guestSurname’ ). value })
}
if ( $w ( ‘#standbyGuestsSelection’ ). checked ) {
returnValues . splice ( returnValues . length , 0 ,
{ “name” : “standbyGuestsNames” , “value” : $w ( ‘#standbyGuests’ ). data })
}
return ( returnValues );
}