100 Posts
root
2 months ago
13
Topic

Hi friends,

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

Get a VIP membership
100 Posts
root
1 month ago
2
Level 1

Appreciated sebloders,

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.

Kind regards
-Adonay

16 Posts
Mikeherbo
1 month ago
1
Level 2

Hi Root,

Same here and I don't know what to do.

I have tried many things like you but with no result and actually it's on VARCHAR...

100 Posts
root
1 month ago
0
Level 3

Hi Mike,

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.

1 month ago
3
Level 1

Hi Root,

I was able to reproduce the problem and fix available here : https://github.com/Octopoos/SEBLOD/pull/773

Have a good weekend!

100 Posts
root
1 month ago
2
Level 2

Hi Olivier,

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.

Thank you! Have a good weekend you too.

-Adonay

1 month ago
1
Level 3

Hi root,

This new issue is not related to the fix as it also happens without it. Trying to find a workaround for this one too.

Regards,

100 Posts
root
1 month ago
0
Level 4

Hi Olivier,

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!

Many thanks for your help!

Best regards.

-Adonay

100 Posts
root
1 month ago
4
Level 1

Hi!

Now the field can be succesfully created from the backend, but in the frontend if we left the date field of the form empty, it throws the same error: Incorrect date value.

Kind regards

1 month ago
0
Level 2

Hi Root,
I'm checking this one today.
Regards,

1 month ago
2
Level 2

Hi Root,

By front end, you mean the content view of your content type ? Do you have any typo/variation or any configuration that manipulates the Calendar field before rendering.

I've tried to reproduce the error but can't succeeed neither on list view nor content view.

Regards,

100 Posts
root
1 month ago
0
Level 3

Hi Olivier,

I mean to let the date field empty in the site form and then try to save the form.

Thank you

-Adonay

100 Posts
root
14 days ago
0
Level 3

Hi,

There is no typo or manipulation from a before render or something, just the form with a lot of date fields.

Is it definitely my problem?

Best regards.

-Adonay

16 Posts
Mikeherbo
Yesterday
0
Level 1

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.

Get a VIP membership