elphin
September 4, 2024, 3:17pm
1
I try to save a form to a database where one field is not required.
It works fine except when I leave that input empty. Then I get this error: "Incorrect integer value: '' for column..."
That column is an integer field and Wappler is trying to insert and empty string value there, which gives the error.
How can I get arround this 'problem'?
Notum
September 4, 2024, 3:21pm
2
Just add condition on insert:
In that case - value will be inserted only if variable from post is not empty.
1 Like
brad
September 4, 2024, 3:31pm
3
You can add a default of now to your Post Value. This will force a null value if there is no input value.
Note: When you add. this using the UI it adds single quotes around 'null'. You have to manually remove the single quotes.
I have a form that has a hidden form field that I would like its value to be NULL. I can leave it blank and it removes any data in that field but I need the data to be entered into the database as NULL so that my filtering works as I need.
Or is there a better way to enter NULL data when a form is submitted?
elphin
September 4, 2024, 5:10pm
4
Thanks Notum and brad for your help!
Both solutions should solve my issue.
On to the next challenge!
brad
September 4, 2024, 5:20pm
5
Note: Having a condition as the first suggestion suggests will not work on an Update Form if you clear the input as it will only update if there is a value. So if you are using ths on an update form you should use the default to null method.
1 Like