I'm working with latest J4 and Seblod 4 on a complex content type, like many others that I have already created, but I have found a problem that I am surprised that no one is having, or at least I have not been able to find it either on github or here.
Very simple to reproduce:
Go to Fields, new field, put title, name, and type JForm - Calendar. At this point it depends if you want a date or a datetime. In my case is Show Time -> Hide because I just need a date field. Storage format raw according to this issue in order to prevent to lose one day every time we edit the form.
And then the storage, I use Standard -> Free -> mydb_column -> mycolumn_name -> Alter table -> Add Column -> DATE (or DATETIME if you need time also)
And after saving it throw the error:
Save failed with the following error: Invalid default value for 'mycolumn_name'
If I create the mysql column by hand, that also causes an error when filling out the form and leaving the date field empty. The form cannot be saved due to the same error.
Any help or fix will be appreciated Best regards. Adonay
I will try a different approach to this question, perhaps simpler.
Working with Joomla 4 (current version) and Seblod 4.1.1:
Does anyone have a form with a date field (or datetime) that can be left in blank (and visible and activated) when the form is saved? If so, how is the configuration of your field in both, seblod and mysql? (I hope no one tells me that her/his date field is a varchar)
I'm stuck with this... And it seems quite silly because no one is having this problem, apparently.
According to the current Joomla database structure, if I take a look to the #__content table, I can see:
In Joomla 3 a date or datetime field should has 0000-00-00 or 0000-00-00 00:00:00 as default value and never be NULL.
In Joomla 4 a date or datetime field that can be left in blank should be NULL as default value, and if it can't be left in blank (it's always filled when submiting the form) it should be NOT NULL and it should not have a default value.
So, I suppose (IMHO) in Joomla 4 the date or datetime field created through Seblod should be NULL as default value in order to avoid this error or the impossibility to create a date field. The field JForm Calendar needs some tweaks and fixes, that's obvious.
I've tested that file some minuts ago. Now, when I select storage "Free" and select my table #__mycontentype, after saving the field is created under #__cck_store_item_mycontentype. So now is not possible to save the field to the desired location.
I'm sorry... A very silly mistake by my side. Yesterday, after selecting the column name and also selecting ALTER TABLE and DATE type, I forgot to change from "Set Data Type" to "ADD column". That's why I got this other problem, but I think this one is not important.
I tried it again today and I can confirm the main problem is solved. I owe you one! Or three!
Hi, now with the fix i can store null value in Datetime format but if there is 2 calendar fields or more on the same form, they all need to be filled or they are store as NULL for all the fields. If they are all filled, values are correctly stored.
To be clear, if one or more calendar fields in a same form are not filled, no values at all are stored and all calendar fields have NULL values.