Possible BUG - Date Element

nbradshaw

Active Member
Fabrik 8.1 (haven't tested on Github yet)

Date element will set current date to (now) even with 'Default to current date' = NO and 'Always return today's date' = NO

This will only happen when 'Allow typing in field' = No
I have my List/Form format = Y-m with Local Time.

----
When I change 'Allow typing in field' = Yes - the problem goes away (date does not get updated)
 
I can't replicate this. With 'Default to current date' = NO and 'Always return today's date' = NO, it behaves correctly, regardless of "allow typing". I've also tried setting store as Local Time, no difference.

-- hugh
 
OK - I think I further isolated it.

I set the date format (list and form) to Y-d...this appears to be when it causes the issue. When I do Y-d-m H:i - the problem goes away.
 
Ah, I didn't notice that part, my brain automatically saw Y-m rather than Y-d.

OK, in which case it's a problem in the date widget itself, not in Fabrik. When setting up the date widget on form load, we rely on the widget's built in ability to parse date formats, and over the years we've found that it can't handle some "non standard" formats. And Y-d is very non-standard.

Yup ... that's it. If you open the date picker, you'll notice that it's set to "today", not the date showing in the field. That's because when we init the date picker, the Y-d format is blowing its tiny mind, and it's just setting it as today. So when the form submits, and we get the date from the calendar picker to submit, we're getting that bad date.

Fortunately, there's a workaround. Under "Advanced", set the "Advanced Formats" to "Yes". As per the tooltip:

When using certain 'non standard' format strings for your date formats, you may find that dates on your form inputs don't behave correctly. If this happens, try enabling this option, which will include a more advance format handling JavaScript library. This adds about 40k to the page load, which is why we don't enable it by default

I just tested here, and it seems to fix it.

NOTE - it is still going to change the month. That's unavoidable. You've told the date to only accept input of year and day, so month is guesswork, and it's going to get set to current month when the date is initialized.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top