Hi all - hopefully a simple one but it’s defeated me. I have a form + form repeat inserting into a main table + subtable in the database. The subtable includes two date fields which are optional.
If I complete both the date pickers then everything works perfectly.
If I leave one or both blank, then I get 500 (internal server error). I can’t find any further information on the error (network in dev tools is blank). Both the date fields allow null values in the database and are type “Date”.
I’m guessing it’s something to do with whatever the date picker is or isn’t posting but I can’t see how or where I can add something to say ignore if invalid / blank.
Any thoughts, ideas or guidance would be much appreciated!
There are 2 validation spots… Client-side and server-side. I suppose on client-side these date fields are not REQUIRED (validation rules) but they are REQUIRED on server-side…
Please check your serverAction your POST validation rules for these fields.
(open the input dropdown, click on these date fields and check if they have the required option checked (on the right side)
Thanks @famousmag for the quick reply. No - I haven’t set any validation rules at all while just trying to get the basic functionality to work first. I just checked and the validation rules section you screenshotted is completely blank for everything.
If it makes any difference, it’s Node / MySql / Docker
That case was helpful as I didn’t realise you can click in (as per last screenshot). It didn’t help, but could I perhaps use the condition column to fix this?
Everything works perfectly when the dates are filled and / or other optional fields are left blank. So it’s not an error with mismatched names or anything like that. I’m going to try building a simple form to insert directly to the subtable, to check if the error is related to the fields or the repeat.
Just checked and I get exactly the same behaviour when inserting directly to the subtable so it’s nothing to do with the repeat.
Both fields allow null here:
Anywhere else I should check? I find the db manager extremely buggy and missing some features e.g. changing (M,D) for decimal types, which has caused problems for me before
It doesn’t say anything else - or at least I can’t see anywhere else to find more info. I’m in debug mode and there’s nothing on the network tab. I also checked excluding those fields from the form and in that scenario everything works. So DB definitely is OK with those fields being blank. It’s just whatever the datepicker is sending is not a valid date and not being accepted as ‘null’ / ignore.
I have the dev tools open when I submit but it remains blank.
Really appreciate you looking at this. I’m giving up for tonight and will try again with a clear head in the morning. I’m pretty sure it’s a problem with a date-picker in a form being left blank - I just don’t think Wappler / serverconnect allows it
@famousmag - I already tested changing the datatypes in the parameters and it doesn’t do anything. I think everything is posted as text anyway. The issue only occurs if the date-picker is blank.
It seems the date picker is sending ‘’ which the database is interpreting as not a valid date instead of null or blank