Hi guys,
I'm working on a custom user form for a class signup page. Website is howlang.org/1-on-1. It's a multipage form with various types of inputs. This morning it was working perfectly, but after making some page edits and changes to the dataset, none of the submit buttons work anymore. The pages of the forms are all separate with their own URLs. The submit buttons submit the input fields and link to the next page. I followed another Velo tutorial on creating a multipage form and combining the rows in the dataset, so the code below pertains to that. The code works fine, so I believe the problem is the dataset, since the problem occurs on all pages of the form.
The custom user input forms I'm having trouble with can be found at these URLs:
howlang.org/1-on-1 (at the bottom of the page)
howlang.org/1-on-1-signup-languages
howlang.org/1-on-1-signup-level
howlang.org/1-on-1-signup-schedule
howlang.org/1-on-1-signup-lessons
howlang.org/1-on-1-signup-review
howlang.org/1-on-1-signup-hours-confirmation
howlang.org/1-on-1-signup-tuition
Don't ask me why I did it this way, please. It's too late now. I've logged nearly a hundred hours on learning about the code and trying to make this thing work.
Here is the multipage form code I'm using (remember, this code is functional and not the issue at hand):
PAGE CODE:
import {session} from 'wix-storage';
$w.onReady(function () {
let formId = session.getItem('formId');
if (formId === null)
{
formId = Math.random().toString();
session.setItem('formId',formId);
}
$w('#formIdInput').value = session.getItem('formId');
});
BACKEND CODE:
import wixData from 'wix-data';
export function combineRows (formId)
{
wixData.query("myclass").eq("formId", formId).find().then
(
(result) => {
let rows = result.items;
let rowIds = [];
//Collect ids of the rows that need to be removed from collection
for (let row of rows)
{
rowIds.push(row["_id"]);
}
//Go through each row, and add the row data to the first row
for (let index = rows.length - 1; index >= 1; index-- )
{
//Go through each field in each row, and add field value to the first row
for (let field in rows[index])
{
if (rows[index][field] !== null)
{
//Assign field data on each page to the same field on the first page
rows[0][field] = rows[index][field];
}
}
}
//Remove all the rows from collection
wixData.bulkRemove("myclass", rowIds)
//Insert the combined row (the first row) to collection
.then
(
(removeResult) => { wixData.insert("myclass", rows[0]); }
);
}
);
}
import {session} from 'wix-storage';
import {combineRows} from 'backend/multi-page-form';
$w.onReady(function () {
let formId = session.getItem('formId');
if (formId === null)
{
//Generate an unique id for the multi-page form
formId = Math.random().toString();
//Save the form id to browser session memory
session.setItem('formId',formId);
}
//Assign formId in session memory to the form on page
$w('#formIdInput').value = session.getItem('formId');
combineRows(formId);
});