Question:
I have created a customized form on my website and it works fine sending all needed inputs to my form dataset. However, I would also like to send another dynamic value to my form dataset. This value is not part of the form (let’s say for instance the title of the page) and it is dynamic, since it is connected to (another) dataset.
What should I do?
Product:
Wix Editor
What are you trying to achieve:
I want that when a user submit my customized form, I receive either information from input elements of the form as well as another dynamic text element present in the page.
What have you already tried:
I tried to run this Velo code and it does not work:
import wixData from 'wix-data';
$w.onReady(() => {
$w("#button7").onClick(() => {
$w("#Agriturismi").onReady(() => {
let currentItem = $w("#Agriturismi").getCurrentItem();
console.log("Current Item:", currentItem);
let propertyName = currentItem["propertyName"]; // ✅ Correct Field ID
console.log("Property Name Retrieved:", propertyName);
if (!propertyName) {
console.error("Error: Property Name is undefined or empty.");
return;
}
let formData = {
"propertyName": propertyName, // ✅ Now using the correct field Id
};
wixData.insert("Booking Reservation Form", formData)
.then(() => console.log("Data saved successfully!", formData))
.catch(err => console.error("Error saving data:", err));
});
});
});