How to set a hidden fields value in a form with setFieldValues? It won’t recognize my field keys.
Wix Studio (Dev Mode)
I am trying to send out automated mails for myself from a form in a lightbox. The form has an email (given by user), package title and quantity which is set by the user right before the lightbox opens up. So basically what I need is to pass the data (package title and quantity) and then set as values for the two hidden fields in the form later. The only visible field would be the email, the others are set before. After submission I wanna get the automated email with the user’s given email address and the hidden field’s values. My problem is that even with the proper field keys I get this error message again and again: Object literal may only specify known properties, and ‘package_title’ does not exist in type ‘FormValues’. (package_title and quantity are the correct field keys tho.)
My code (lightbox):
import wixWindowFrontend from ‘wix-window-frontend’;
$w.onReady(function () {
const receivedData = wixWindowFrontend.lightbox.getContext();
$w('#form2').onSubmit((values) => {
$w('#form2').setFieldValues({
package_title: receivedData.packageTitle, // Set the value for the "package_title" field
quantity: receivedData.quantity // Set the value for the "quantity" field
});
});
});
Code before the lightbox (package page - which seems to work properly and it correctly passed data to the lightbox later):
import wixWindow from ‘wix-window’;
$w.onReady(function () {
$w('#repeater1').onItemReady(($item, itemData, index) => {
$item('#button1').onClick((event) => {
const quantity = $item('#dropdownQuantity').value;
const packageTitle = $item("#text23").text;
if (!quantity) {
console.error("Please select a quantity.");
return;
}
wixWindow.openLightbox("Packages Lightbox", {
quantity: quantity,
packageTitle: packageTitle,
});
});
});
});