I use the following way to set values of form fields programmatically.
$w.('#fieldName').value = 'some data'
I have several UserInput fields. They are all connected to a database collection. If I enter data manually into all of the fields, they all get stored in the database. If I use code (like stated above) to enter data to some fields - those fields will not get stored while other fields (with manually entered data) will get stored.
I used console.log() to see if values were set the same way for the manually entered fields and the programmatically entered fields - it looks the same.
I tried manually appending a character to the programmatically entered fields and then the entire data (programmatically entered and manually entered) was stored.
I am guessing that there is some kind of an attribute on each field that indicates whether it was changed or not, and setting the values using code does not trigger the attribute change to reflect the true state of the field.
I hope I am missing something - like a click on some attribute or something.
Please help
facing same issue
Are you sure you use setFieldValue() before saving? Look at the docs: https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue
or this doc, in e.g. TextInput.value
"If an element is connected to a dataset, setting the element's value in code does not set the value of the connected field in the dataset. That means if you use the dataset to perform a submit, the value changed in code is not reflected in the submitted item.
To submit the new value using a dataset, set the field's value using the setFieldValue() function before performing the submit."
Was this ever resolved? I am having the same issue - i.e. fields populated by wix code do not get updated into the database.
I face the same problem with fields populated with jquery. The fields go blank when another field is changed either programmatically or manually. Did you find a solution to this?
Alon, I will give you the same workaround as I did in the above case, assuming that you use a standard submit button attached to the dataset (in ots props you set it to Submit).
Detach the button fron the dataset (turning it into a normal button) and on the onClick, do a .save(). That should work.
Yes, I searched quite a lot but didn't find anything relevant :-(
This issue has been raised on this forum a couple of months ago. I think I remember it was a bug and wix fixed something and asked the issuer to try it agian. Unfortunately, I cannot remember by whom. Have you tried searching this forum on a couple of keywords?