Forums

(solved) date picker

chrissy6930 01 Jun, 2011
hi all,

after trying to adjust the date format (instead of 2011-06-10 I'd like to have 10. Jun 2011)applying the following changes:
- added a field class (date_picker_1) to the date element in form wizard
- on the general tab in form manager added date_picker_1::{inputOutputFormat: 'j. M Y'}

only now none of the validations in my form is working any longer (required fields do not through any errors), the date form doesn't even show the calendar and the firefox / firebug console displays the following error:

missing : after property id
new DatePicker('.cf_date_picker', {pickerClass: 'datepicker_dashboard', format: 'Y-m-d', inputOutputFormat: 'Y-m-d', allowEmpty: true, date_picker_1::{inputOutputFormat: 'j. M Y'}});
addresults (line 35)

what am I overlooking ? and what is 'after property id' ?

J!1.5.23, CF 4 RC1.9
GreyHead 01 Jun, 2011
Hi chrissy6930,

It looks as though Max has changed the data-picker syntax in the new RC 1.9 release.

On the Form General tab | DateTime Picker config box please try replacing
date_picker_1::{inputOutputFormat: 'j. M Y'}
with
inputOutputFormat: 'j. M Y'

Bob
chrissy6930 01 Jun, 2011
thanks bunches for the hint! that fixes the error!😀
chrissy6930 02 Jun, 2011
however the change in date format is not working.
on my forms for displaying data I still see the date in default format 'Y-m-d' - for existing data; for new entries the date would be displayed as 0000-00-00 (which is what is being posted to db instead of the date selected).
GreyHead 02 Jun, 2011
Hi chrissy6930,

The inputOutputFormat option only changes the format used for saving (and loading) the dates - it doesn't affect the format used for displaying them. Use the format: 'xxx' option for that.

The option list is here

Bob

Later: I corrected the post to the option list; previously it pointed to the newer version of the datapicker here - this version is not currently used in ChronoForms.
chrissy6930 02 Jun, 2011
I am sorry but I'm not getting this:

I tried in my form listresults

format: '%e. %b %Y'
format: 'e. b Y'
format(%e. %b %Y)
format(e. b Y)

but none of them changes the display format 😶
chrissy6930 03 Jun, 2011
any news on how to get the displayed date format adjusted ?
GreyHead 03 Jun, 2011
Hi chrissy6930,

My apologies, I linked to the wrong version of the DatePicker docs (I've corrected my post). Please try this in the DateTime Picker config box
format: 'j. M Y', inputOutputFormat: 'j. M Y'
Note that you have to use single quotes to stop the option values from disappearing.

Bob
chrissy6930 04 Jun, 2011
thanks again Bob !

welll...

I set
DateTime Picker config = format: 'j. M Y' in form listresults
and
DateTime Picker config = inputOutputFormat: 'j. M Y' in form addresults

however
upon submission of a new entry the date would be saved in table as '0000-00-00' (<- this is not the format but the actual value of the date field) ('addresults')
when displaying data the date is still not displayed in the desired format ('listresults')

*pulls hair*
GreyHead 05 Jun, 2011
Hi chrissy6930,

If the column in the database is of type 'date' then the data has to be correctly formatted to be saved - I think that the default MySQL date format is 'Y-m-d'; if you use any other format to save then you will either get the wrong date, or the default '0000-00-00'.

Bob
ironlion37 06 Jun, 2011
Hi, I just tried to make sense of this thread with the intention of changing the way the date picker displays dates from "2011-06-07" to "06-07-2011".

Where is the DateTime Picker config box located?

Thanks!
GreyHead 06 Jun, 2011
Hi ironlion37,

It's at the bottom of the form General tab (click the form name link in the Forms Manager to open it).

Bob
chrissy6930 07 Jun, 2011

If the column in the database is of type 'date' then the data has to be correctly formatted to be saved - I think that the default MySQL date format is 'Y-m-d'; if you use any other format to save then you will either get the wrong date, or the default '0000-00-00'.



yes that is making a lot of sense. I have thus removed inputOutputFormat: 'j. M Y' from form addresults

but the format of dates displayed in listresults is still Y-m-d (2001-06-11) and not in the desired format: 'j. M Y' (11. Jun 2011) please view my attachment above called 'listresults.jpg'

what is necessary for format: 'j. M Y' entered in DateTime Picker Config field to actually trigger a change in the format of the displayed dates ?
chrissy6930 08 Jun, 2011
instead of trying to make it work using the DateTime Picker config I cleared the field and instead have amended the respective custom element of form listresults:

instead of
<?php echo $detail['date']; ?>

I am using
<?php echo JHTML::_('date', $detail['date'], JText::_('%e. %b %Y')); ?>

now all is working
GreyHead 10 Jun, 2011
Hi chrissy6930,

That looks like a neat solution. :-)

Bob
This topic is locked and no more replies can be posted.