In your case you can also insert null as a default value, as an empty string is not allowed. Example:
{{$_POST.est_first_pay_date.default(null)}}
In your case you can also insert null as a default value, as an empty string is not allowed. Example:
{{$_POST.est_first_pay_date.default(null)}}
OK yes - thank you, this is definitely the issue. The date picker is sending an empty string and the database is not accepting that as blank / null.
Is there a way in Wappler I can convert the empty string to a null value, or change the DB setting? Or if I use the condition column in the insert query, can I say to only insert that field if it is not an empty string?
It sounds like it’s not possible and I need to use workbench or similar to change the settings in the database directly.
Sorry didn’t see this - I’ll give this a try
Teodor gave us the problem explanation…
And a solution
Thank you neighbor!!
Unfortunately I don’t think I can use this because the field is part of a subtable (so following this method: Inserting Data in Main and Sub Table using App Connect Form Repeat - Docs / Server-side Components - Wappler Community
Unless there’s somewhere else I can insert it? As it stands, the $Post is the array and the names match the database fields.
Otherwise, I guess I can build the repeat manually
In case others have problems with empty date pickers, I tested writing directly to subtable using this and it worked perfectly.
As far as I can see, I can’t apply it to inserting into a main table and sub-table via a form-repeat though as I can’t edit the $_Post for the fields in the subtable. However, it should work if I manually create a repeat in the server action instead of using the Wappler inbuild shortcut.
Thanks again to you both
Try using the condition option here instead {{$_POST.est_first_pay_date != ''}}
I tried but it didn’t work (still tried to insert the empty string):
Not sure if it’s supposed to be referencing the formrepeat? If I select it in the picker I get this, but I guess I would need to correct [0] for some sort of $index.
$_POST.formRepeatExposures[0].est_first_pay_date!=''
In any case - I can easily make a repeat in the server action and that will definitely work.
Ok i understand the problem, we should improve the sub table insert process and allow some data formatting to be applied @patrick
Meanwhile you can connect to your db with some third party tool like mysql workbench and set the sql_mode to ALLOW_INVALID_DATES
Just to close this off and for anyone reading in future:
I found the best solution was to use a repeat in the server action (to insert to the subtable directly) and not use the main table/ subtable insert process. Reasons being:
Many many thanks again for the super fast responses and help with this.