I am trying to add user’s entries to the database, which I can successfully do as well. However this is creating some new fields using the name of the fields that I have already used in my database.
For example, if you zoom in into the photo, you will see that I already have a name field in my collection. However, when I add the user’s input to the database, it is creating new fields instead of using existing ones.
The Codes are here below:
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
//$w.onReady(function () {
//TODO: write your page related code here…
//});
export function formsubmit_click(event) {
//Add your code for this event here:
var fieldInputs =
var checked_inputs =
// collect the inputs from the checkboxes
for ( var i = 2; i <= 7; i++) {
if ($w(‘#checkbox’ + i).checked)
checked_inputs.push($w(‘#text’ + (i-1)).text)
}
if ($w(‘#checkbox8’).value !== ‘’) {
checked_inputs.push($w(‘#checkbox8’).value)
}
// Add the rest of the form input
for ( var j=1; j<=5; j++){
fieldInputs.push($w(‘#input’+j).value)
}
fieldInputs.push(checked_inputs)
fieldInputs.push($w('#uploadButton1').value)
var dataStructure = function (Name, Surname, Email, Phone, Services, Description, Photo) {
this .Name = Name;
this .Surname = Surname;
this .Email = Email;
this .Phone = Phone;
this .Services = Services;
this .Description = Description;
this .Photo = Photo;
}
var toInsert = new dataStructure(fieldInputs[0], fieldInputs[1], fieldInputs[2], fieldInputs[3], fieldInputs[5], fieldInputs[4], fieldInputs[6])
console.log(fieldInputs[0])
wixData.insert("member_profile", toInsert)
.then( (results) => {
let item = results; //see item below
console.log(‘Data upload successed!’)
wixLocation.to(/services
);
} )
. catch ( (err) => {
let errorMsg = err;
console.log(‘Data upload failed!’)
wixLocation.to(/about-us
);
} );
}