Hey!
Do you know how could I custom a registration form + update the information on the database?
I tried with the Wix function (connecting each field to the database and to submit) but its not working.
Right now I have this:
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
$w.onReady(function(){
$w('#register').onClick(function (){
let updates = {
"companyName": $w("#companyname").value,
"email": $w("#email").value,
"password": $w("#password").value,
"title": $w("#name").value,
"_id": wixUsers.currentUser.id
};
wixData.save("Company", updates)
.then( (results) => {
wixLocation.to("/welcome");
} )
.catch( (err) => {
let errorMsg = err;
} );
let email = $w('#email').value;
let password = $w('#password').value;
wixUsers.register(email,password,{
"contactInfo": {
"title": $w('#name').value,
"companyName": $w('#companyname').value,
}
})
.then( ()=>{
wixLocation.to('/welcome');
})
})
})
But I also tried this:
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
$w.onReady(function(){
$w('#register').onClick(function (){
let email = $w('#email').value;
let password = $w('#password').value;
wixUsers.register(email,password,{
"contactInfo": {
"title": $w('#name').value,
"companyName": $w('#companyname').value,
}
})
.then( ()=>{
wixLocation.to('/welcome');
})
})
})
export function register_click(event, $w) {
let updates = {
"companyName": $w("#companyname").value,
"email": $w("#email").value,
"password": $w("#password").value,
"title": $w("#name").value,
"_id": wixUsers.currentUser.id
};
let req1 = $w("#companyname").valid;
let req2 = $w("#email").valid;
let req3 = $w("#password").valid;
let req4 = $w("#name").valid;
if (req1 === false || req2 === false || req3 === false || req4 === false)
$w("#errorText").show();
else
{wixData.save("Company", updates)
.then(() => {
//go to welcome page
wixLocation.to("/welcome");
})
.catch( (err) => {
console.log(err);
} );
}}
Because I read somewhere that they had problems with fields that had the required option.
Thanks!!