Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Date fields are not saving 05 Jan 2013 00:40 #6353

I'm running V2 beta version (in the sandbox) and I have date fields in my tables that I fill in on my form pages (both frontend and backend. These used to work, but right now the data is not being saved. The create and modified date wizards are working fine so I'm not sure where to look.

Thanks!
Dave

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 10:17 #6355

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi there,

A couple of things to try:
  1. Remove the fields, then re-adding them
  2. Try another table/layout with just the date fields on
Let me know if this helps...

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 17:10 #6356

deleted date field from the table and re-added to table and forms and it still fails.

Having said that, I stumbled on the cause (but not solution) ... if I don't specify a date format it works but when I change the date field in the table to mm-dd-yyyy it doesn't save the data

Dave

PS. I've tried specifying mm-dd-yyyy in both the table and the form and that doesn't help

Please Log in or Create an account to join the conversation.

Last edit: by dyoungers. Reason: additional info

Re: Date fields are not saving 06 Jan 2013 17:38 #6357

after thinking about this, it seemed to me that the problem was likely related to date format and the code for converting the date so on a whim I set the date fields to be stored in UNIX format. That didn't help as all dates are stored as 01-01-1970 (so a problem converting dates from form's posted data)

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 18:03 #6359

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
When you say that they're "not saving", are they giving you an error - JS or PHP?

Are you using Mootools or jQuery?

G
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 18:53 #6360

No errors ... running in the sandbox using V2.0 beta and JQuery

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 18:59 #6361

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
can you try this locally with debugging on?

Have you tried a new, single table component with same config?

Dates are handled in administrator/components/[your_component]/helpers/dates.php

G
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 19:18 #6362

I just created a new test project and it has same problem

I will try and download yet today (why am I working today ;)) and look at locally so stay tuned

Dave
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 06 Jan 2013 22:34 #6365

No errors on my local server either but when I set the date value in the database directly (php
MyAdmin) the dates are displayed in the list view and form view correctly, i.e. converted from SQL dates to mm-dd-yyyy (as I've defined for the field in the table)

I'm new to Cook (and to the Joomla MVC for that matter) but I started digging around and I set a breakpoint in the prepareTable method in the item's model and the date is still in the mm-dd-yyyy format at the start of the function and I don't see any code to convert the date so my next question is "where should it be converted to an SQL date?"

Thanks!
Dave

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 07 Jan 2013 21:27 #6373

I did some more digging in the version I generated yesterday and I put code in prepareTable to store the dates correctly and while that took care of saving the dates I then discovered that the dates cause an error on my form (works on list view)

It looks like the there is code in the calendar class that formats the date before creating the form field (apparently so it displays right?) but the following exception is thrown when creating the form field:

DateTime::__construct(): Failed to parse time string (01-23-2013) at position 0 (0): Unexpected character

Hope this helps someone fix this

Thanks!
Dave

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 23 Jan 2013 09:22 #6494

  • g1smd
  • g1smd's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
If this is a web application that's going to be seen on both sides of the Atlantic, you might try the 2013-01-24 format as this is the only unambiguous numerical format.

01/10/2013 could be 1st October or January 10th.

2013-01-10 is always January 10th.

See ANSI X3.30, EN 28601, ISO 8601, RFC 3339 etc.
Online since 1996.
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 27 Jan 2013 16:47 #6538

in this case, it's a custom component where they initial customer wanted mm-dd-yyyy

If I decide to make it available publicly, I'd likely make the date (and time) formats customizable

Please Log in or Create an account to join the conversation.

Re: Date fields are not saving 02 Feb 2013 22:00 #6612

Finally have this working the way I'd like, i.e. using mm-dd-yyyy date formatting.

In the process of getting things working, I discovered a problem with the calendar class (admin\dom\html\form\input\calendar.php) so I made a change there (and in my item's model)

The calendar class generated a run-time error because it was using the formatted date to create a date object so some of the other date formats cause errors and it just seemed that a simple fix would be to change the calendar class to use the raw date value (in SQL format) instead.

The following three lines of code were changed in the calendar class:

Line 143 (pass the date without formatting)
$html = self::calendar(
					$formatedDate,
					$this->getInputName(),
					$this->getInputId(),
					...
to
$html = self::calendar(
->					$this->dataValue, $formatedDate,
					$this->getInputName(),
					$this->getInputId(),
					...
Line 173 (function declaration)
public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $config = array())
to
public static function calendar($value, $formated_date, $name, $id, $format = '%Y-%m-%d', $attribs = null, $config = array())
Line 244 (show the formatted date)
return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '" name="' . $name . '" id="' . $id
			. '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
			. ($readonly ? ''
			: JHtml::_('image', $imgBaseUrl . '/calendar.png', $imgAlt, array('class' => 'calendar', 'id' => $id . '_img'), true));
to
return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '" name="' . $name . '" id="' . $id
->			. '" value="' . htmlspecialchars($formated_date, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
			. ($readonly ? ''
			: JHtml::_('image', $imgBaseUrl . '/calendar.png', $imgAlt, array('class' => 'calendar', 'id' => $id . '_img'), true));

For now, in order to get the values to save, I added code in the item model's "prepareTable" method to convert the date back to SQL format but at some point, I'll look for a more global fix since I'd rather not have to do this every time I add a date field.

Hopefully this is useful to others (and maybe the calendar class would be updated if this makes sense for all users?)

Dave
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Last edit: by dyoungers. Reason: typos

Re: Date fields are not saving 27 Feb 2013 19:18 #6869

I see that the code being generated for saving mm-dd-yyyy date fields is working now :)

The code still causes an error when opening a form with an input for the date field (grid view works)

Same message as before so I assume the calendar class hasn't been fixed yet
500 - DateTime::__construct() [datetime.--construct]: Failed to parse time string (01-15-2013) at position 0 (0): Unexpected character

Not a big deal, just hoping to see the fix when next version is released :)

Thanks!
Dave

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.086 seconds

Let me first state that this is an amazing and fascinating product exactly what I was looking for. In just a few hours (listening to the very well made and clearly understandable videos learning doing) I completed and installed my first component. I am now in the second refining phase. I will make a recommenation in JED. Thanks for the effort in creating such a great product. Incidentally some of the best Joomla extension I use are of French origin !
Giori (Forum)

Get Started