Forums

Again: Strange behavior of custom datepicker

jack19 30 Oct, 2013
Hello to all,
I have a problem with custom datapicker.
the configuration is:
Date format shown = d-m-Y
Date format posted = Y-m-d
Extra option extension:
months:['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],days:['Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato'],startView:'decades'


but after selecting the month is shown again a year.
See:

there seems to be the level of the years below the level of the month and when you click it takes the value one year instead of the month.
Any idea?
Best regards.
Gioacchino

P.S. Joomla! 2.5.14 - Chronoforms_V4.0.1_J2.5

News: Work only in IE.
GreyHead 30 Oct, 2013
Hi Jack,

Unless you are using Joomla! 1.5 I suggest that you switch to the MooTools DatePicker. I think that may well solve this problem.

Please see this FAQ

Bob
jack19 31 Oct, 2013
Ok Bob.
Tank You.
Best Regards
Gioacchino
jack19 31 Oct, 2013
Hi Bob,
There are still problems.
Activating mootools datepicker you see so.
[attachment=0]moo.jpg[/attachment]
Two datapicker overlapping, moving first up is the default, in the second level is the Custom Datepicker Mootools.
🙄 🤨
Best regards.
Gioacchino
GreyHead 04 Nov, 2013
Hi jack19,

I think that this is an irritating ChronoForms bug; when you add a custom class the old one is retained and ChronoForms sees that and adds a default datepicker too.

I get round this by using an Input Text element instead of a DatePicker element so I have complete control over the class. If there are no default datepickers on the page you may also need to load the DatePicker scripts.

Here's one I built recently based on another forum post.

In a Custom Code action in the On Load event add this:
 <?php
$document =& JFactory::getDocument();
// make sure that MooTools is loaded (this is Joomla! 3 code)
JHtml::_('behavior.framework', true);
$cf_url = JURI::root().'components/com_chronoforms/js/datepicker_moo/';

// you can change the uncommented line here to change the style
$datepicker_style = $form->form_params->get( 'datepicker_moo_style', 'datepicker_dashboard' );
$document->addStyleSheet( $cf_url.$datepicker_style.'/'.$datepicker_style.'.css' );

// load the datepicker script files
$document->addScript( $cf_url.'Locale.en-GB.DatePicker.js' );
$document->addScript( $cf_url.'Picker.js' );
$document->addScript( $cf_url.'Picker.Attach.js' );
$document->addScript( $cf_url.'Picker.Date.js' );
?>

and to configure the datepicker, in a Load JS action:
window.addEvent('domready', function() {
  var max_date = new Date().decrement('year', 16);
  new Picker.Date($$('.year_picker'), {
    pickerClass: 'datepicker_jqui', 
    format: '%Y-%m-%d',
    allowEmpty: true,
    useFadeInOut: !Browser.ie,
    startView: 'years',
    maxDate: max_date
  });
});

Note: this uses the jqui stylesheet and sets a year start view for a date of birth with the first enabled date 16 years ago.

Bob
jack19 04 Nov, 2013
Hi Bob,
There is another problem, when saving the date. Will store the value 0
(0000-00-00 00:00:00)
😢
Best regards.
Gioacchino
jack19 04 Nov, 2013
Hi Bob,
don't work.😟
GreyHead 04 Nov, 2013
Hi Jack,

What exactly doesn't work?

I copied the code from a form where it is working so something has got lost in between.

Bob
jack19 05 Nov, 2013

Hi Jack,

What exactly doesn't work?

I copied the code from a form where it is working so something has got lost in between.

Bob


Hi Bob,
when storing the date. Will store the value 0 (0000-00-00 00:00:00).
Note: If I use this format: '%d-%m-%Y'
However, in the format Y-m-d no problem, but in this format also works the datepicker default.
Best Regards
GreyHead 05 Nov, 2013
Hi Jack19,

It looks as id you have a DATETIME column in the database so before saving you need to make sure that the data is in a format that MySQL will recognise as a 'date'.

You can either use a different format for the picker, or use PHP in a Custom Code action to change the format of the 'human readable' date back into a 'MySQL readable' one.

The old datepicker would allow you to use two different formats, one to display, the other to submit; this one doesn't have that feature.

Bob
jack19 06 Nov, 2013
Hi Bob,
thanks for the reply.
I will do as you suggest.
Best Regards.
Gioacchino
This topic is locked and no more replies can be posted.