Open Site Navigation

Velo: Create Dynamic Form Entry

Have you ever wanted a button on a dynamic page that links to a form the user can fill out... but wanted the form to automatically know which dynamic page the user is coming from? I know this is a very specific request, but in this lesson you will learn how to set this up using Velo.


Create Dynamic Form Entry Using Velo in Wix

Before you insert the code, make sure to watch this video to set up your dynamic and form correctly:



Here is the code for the DYNAMIC PAGE:


 

import wixWindow from 'wix-window'; export function btnQuote_click(event) { let current = $w('#dynamicDataset').getCurrentItem(); let dataObj = { "name": $w("#text16").text, "id": current._id } wixWindow.openLightbox("Quote", dataObj); }


 

Here is the code for the quote FORM LIGHTBOX:


 

import wixWindow from 'wix-window'; let receivedData = wixWindow.lightbox.getContext(); $w.onReady(function () { init(); $w('#dataset1').onBeforeSave(() => { console.log("Continuing save"); $w('#dataset1').setFieldValue("product", receivedData.id); return true; }); }); function init() { let option = [ { "label": receivedData.name, "value": receivedData.id } ]; }


 

Make sure you insert the proper names for the database inputs to make it work! Have fun!