Hi!
In my Wix Form, I have a dropdown (selection field). The options are populated from a collection such that the option 's label is a readable text ("ABC Course Name") and its value is a system generated ID ("aca0f0a2-aa6a-4474-b082-5f8990e3c8bb"). When the form is submitted, the email notification sent contains the form field Name and Value pairs. As the value is something unreadable like mentioned, I want to set it to the Label Text. I do this change in the onWixFormSubmit event handler. But it gives the above error, whereas the fieldValue change to a text input field is accepted. Kindly help, i am not able to locate the problem.
$w("#wixForms1").onWixFormSubmit((event) => {
let index = $w("#dropdownCourseName").selectedIndex;
let dropdownoptions = $w("#dropdownCourseName").options;
let coursename = dropdownoptions[index].label;
for (var i=0; i < event.fields.length; i++) {
console.log ("Event field", event.fields[i]);
// dropdown selection field element. Value is set to Text. fieldValue change gives error
if (event.fields[i].id === "dropdownCourseName"){
event.fields[i].fieldValue= coursename;
}
// text field element. Value is set to Text. No error. fieldValue change is accepted
if (event.fields[i].id === "input25"){
event.fields[i].fieldValue= "FIRST NAME";
}
}
return event.fields;
})
Thanks.
Gita
If you don't want to spend too much time figuring it out, maybe you can try to do the value alterations in a beforeInsert data hook.
Forgot to ask...
Where do you set the onWixFormSubmit() function? It should be in the page's onReady().
Do you have any code in the onClick() event handler of the form's Submit button?
Hi,
Try yo change one value only and see if it works.
Try to console.log() the coursename and see what it logs.
Try to console.log() filed value after it changes and see what it logs.