134 Posts
root
1 year ago
21
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 Book for SEBLOD
134 Posts
root
1 year 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

21 Posts
Mikeherbo
1 year 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...

134 Posts
root
1 year 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 year ago
4
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!

134 Posts
root
1 year ago
3
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 year ago
2
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,

134 Posts
root
1 year ago
1
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

11 months ago
0
Level 5

Hi root,

Right, this one is a feature and not a bug. When you create fields for free content type, you have to check 'ALTER TABLE' for the field storage value to be correct and created in the right table.

Regards,

134 Posts
root
1 year 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 year ago
0
Level 2

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

1 year 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,

134 Posts
root
1 year 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

134 Posts
root
1 year 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

21 Posts
Mikeherbo
11 months ago
2
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.

134 Posts
root
11 months ago
1
Level 2

Hi Mikeherbo,

That is how it should be even if you don't have enabled in Seblod options SQL Mode -> Legacy (Joomla! 3). Try to let this option in Auto (newest) and if it is not exclusively my problem, it should fail when saving the form with calendar fields not filled.

As this is a new project started from the scratch with Seblod 4 and Joomla 4, I shouldn't have to use that option.

Best regards.

-Adonay

21 Posts
Mikeherbo
11 months ago
0
Level 3

I have actually SQL Mode ->Auto (newest) settings and it is like this since this new instal...

Have you try on a other form ? I have this issue but a try on a other form and it works. I had try many things on the old form so maybe it change something...!?

One more thing, i have put separated fields for the time and i put a js field to change de time on the datetime.

11 months ago
3
Level 1

Hi guys,

Can we consider this as fixed or you still have a specific problem with the calendar field?

Olivier

134 Posts
root
11 months ago
0
Level 2

Hi Olivier,

I need to try what Mikeherbo said, he must be right.

There is still one problem not solved commented some months ago here. It happens on the search form, it always return one day less.

Also, if you want to take a look, there is this problem regarding timezones, in my case it was solved with storage format -> raw, but the problem is still there.

Thank you all.

Best regards.

134 Posts
root
11 months ago
1
Level 2

Hi,

I have done the tests, without success.

  1. Backed up and replaced file /libraries/cck/_/plugin/field.php with the patched one.
  2. Created a new content type with 4 new fields: id, client_id, type and date.
  3. Ok, the date field is created in the joomla backend, this is solved
  4. Created a menu item pointing to this new seblod form
  5. Fill out the form fields, except the date field. Save the form.

Incorrect date value: '' for column `xxxx_dev`.`yyyy_newtable`.`date` at row 1

So, I can't save a simple form if the date field is empty.

Best regards,

-Adonay

21 Posts
Mikeherbo
10 months ago
0
Level 3

Hi,

I'm still stuck with this field....

If all the calendar fields are not filled in the form, all the fields are not stored and calendar fields have NULL values.

I will try to put some default values with the code pack.

Can someone please check the code here - i don't have enough knowledge to do this :( 

 : https://github.com/Octopoos/SEBLOD/pull/773

and see if there is a mystake with the NULL value.

Thank you so much

134 Posts
root
10 months ago
0
Level 1

Hi guys,

I have set up a new server with php8.2 and all the stuff, installed a new joomla 4.1.1 on it and a new seblod 4.2.0b on it.

After that I tried with exactly the same steps mentioned in my last post here:

  1. Backed up and replaced file /libraries/cck/_/plugin/field.php with the patched one.
  2. Created a new content type with 4 new fields: id, client_id, type and date.
  3. Ok, the date field is created in the joomla backend, this is solved
  4. Created a menu item pointing to this new seblod form
  5. Fill out the form fields, except the date field. Save the form.

Incorrect date value: '' for column `xxxx_dev`.`yyyy_newtable`.`date` at row 1

So at this point I'm pretty sure this is not a mistake on my end and is quite easy to reproduce.

Remaining problems of this field are:

This one and this one.

Merry christmas!!

-Adonay

Get a Book for SEBLOD