Data not getting saved when I click on [Submit]

Hi, all.
I’ve followed the steps in
Velo Tutorial: Creating a Form to Store User Input in a Database Collection | Help Center | Wix.com to create a form but when I click on [Submit], I get a “save operation failed: DatasetError: Some of the elements validation failed.” error message in the Developer Console.

Also in the Developer Console, it indicates “Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.”

I’ve now opened MasterPage.js in Developer Tools but don’t really know what to do next.

Thanks

I followed those same steps and it worked fine for me. You must not have the fields mapped correctly or not matching the field names.

Thanks, Daniel.

I’ve got a ZIP Code input text box linked to the ZIP code column in the database and 2 e-mail address input text boxes linked to their respective columns in the database (all with a dataset linked to the databsae).

Could it be something to do with the pattern validation?

@abergquist , make sure that if you are saving a value from a text field on the screen, that the field in the collection is defined as text. Same thing with Number, Boolean, Image, etc.

Thanks, Yisrael.

All 3 inputs (ZIP code and the 2 e-mail addresses) link to a Text file in the database collection (confirmed by checking the columns in the database collection as well as reviewing the “Value connects to” for each input control).

Hi abergquist:

If you post the page link here one of us can look at the developer console and see what is going on. More often than not, as Ysrael stated, it is likely to be how you have created the dataset bindings.

If you can post a couple of screen shots of the configuration settings you have for the email and zip code and related data collection elements as follows - it will help us help you more effectively:

Input element to data set binding


Dataset to collection configuration


Data collection field info (zip and email1)

Steve

Thanks, stcroppe, here goes:

Dataset to collection configuration:


1st input element to data set binding:


Data collection field info for the 1st input element above:


2nd input element to data set binding:


Data collection field info for the 2nd input element above:


The other e-mail address is correctly linked to its own Text field in the database collection.

What is the URL for the page?

https://www.hnllws.com

(‘xxx’ is the answer to your next question)

Sorry, make that https://www.hnllaws.com

Hi There:

OK you seem to have 2 problems.

  1. One is the zip input field. You have some validation there that limits the input to 5 characters (numbers) you might have a regular expression driving this. It seems to accept 99999 but no other numerical sequence. So take a look at what you have set up for this (Im happy to take a look also).
  2. When the data is valid (in this case 99999) the save fails because you have access privileges set on the data collection which you need to match you the user who is logged into the site I am guessing:

console.js:35 save operation failed: Error: The current user does not have permissions to insert on the ZIP-Code-EMails-Map collection.
Hope this helps!

  1. Ah, good catch; in response, I just replaced the pattern validation of:

99999

with:

^[9]{5}$

That should now allow just 5 digits for the ZIP Code.

  1. WRT Permissions, I set it “Password Holders” so if you enter the correct password, you should have permissions, correct?

Abergquist I suggest you check this out - 4.14. Validate ZIP Codes - Regular Expressions Cookbook, 2nd Edition [Book]

Regarding permission:
The permissions you are referring to are the page permissions. The permissions that the error is referring to is on the dataset which gives you read only, write only or read write. Also on the data collection it self there are also permissions that are much more complex and role based so they depend on the logged in users role (Admin, Member or Visitor).

Thanks again.

I’ve switched the regular expression to:

^[0-9]{5}$

since only going for a 5-digit ZIP code (not ZIP+4).

WRT “Regarding permission:
The permissions you are referring to are the page permissions. The permissions that the error is referring to is on the dataset which gives you read only, write only or read write. Also on the data collection it self there are also permissions that are much more complex and role based so they depend on the logged in users role (Admin, Member or Visitor).”

I have the Mode set to Write-only in the Dataset Settings (I don’t see any other Permissions to set).

Thanks; I’ve opened up (made less restrictive) the permissions:


but it still won’t save (the debugging messages are not really that helpful).

Hi Abergquist

I had some problems with the regexp validation on the text input settings. For some reason the wix validation wasn’t seeing the data in the input element. I figured this out by looking at the .validity state of my text field using the .onCustomValidation function like so.

$w('#zipCode').onCustomValidation((value, reject) => {
    console.log(JSON.stringify($w('#zipCode').validity));
});

If you add something like this you will see what the validity settings are for the zip code field.

One thing you can do if you see a problem is replace the regexp validator you have on the input field…


with a regexp test in an onCustomValidator function like so

$w('#zipCode').onCustomValidation((value, reject) => {             
    console.log(JSON.stringify($w('#zipCode').validity));
    let regExp = new RegExp('^[0-9]{5}$');
    if (!regExp.test(value)) {
        reject('Bad Zip Code');
    } else {
        console.log('good zip code');
    }
});

Hope this helps
Steve

You, my friend, are good!

I took at out the pattern validation for the ZIP Code of:

^[0-9]{5}$

and it now saves to the database collection!

Next up is to try your code.

Thank you SO much; I really appreciate it!

Good to know. Hope you get it sorted !