Forums

datepicker bug : cannot set any min or maxDate

dezi168 27 Sep, 2011
Hi,

I've been testing datepicker options.
I can not set any maxDate.
I used the syntax described in here according to this thread :
minDate:{date:'28-9-2011',format:'d-m-Y'}

I put this value in the 'DateTime Picker config' in the general tab of the form.
In the javascript console, I get this error when the field is focused and the datepicker is not displayed:
Uncaught TypeError: Cannot call method 'toString' of undefined, datepicker.js:670

I have checked on Chrome (V14), FF6 and IE9. I get the same error.

Apparently your are using an old script that is buggy sometimes (and with no support). When you plan to move to the new datepicker ?


I also discovered that you've created a 'custom Datepicker' action.
When putting the code in the 'Extra options extension', the datepicker is displayed :o , but maxDate is not defined 😈 .

I really get confused, which option should we use to set datepicker options ?

A suggestion : in my opinion, every datepicker options should be set in the 'other' tab of each Datetime box element. Today, it is not possible to set different minDate in datepickers of the same form. By coding my suggestion, one could create a travel form with a first 'departure date' datepicker (using today minDate) and a second 'return trip date' datepicker (using previously selected date as minDate).
I really do not understand why you've created the 'custom Datepicker' action, in my opinion it is uselees and confusing. The 'DateTime Picker config' in the general tab of the form is sufficient to set commun options (eg. language, date time formats).

My config : J!1.7.1 CF 4 RC2.0
GreyHead 27 Sep, 2011
Hi dezi168,

Thanks for posting your views.

The one big difference with the Custom DatePicker action is that you can use more than one of them so can have different datepicker settings in the same form. You can't do that with the General tab settings.

Bob
dezi168 27 Sep, 2011
Hi Bob,

Thank you very much for your quick answer.
But it was a little bit short.

It does not give me any explanation about my minDate issue.

I have tried using Cstom DatePicker action, but still does not work 😟 .

I upload a backup of my form. If you could have a look ...
GreyHead 27 Sep, 2011
Hi dezi168,

Sorry, as far as I can see you didn't ask any questions about the minDate. Only when Max might switch the Datepicker library.

Bob
dezi168 27 Sep, 2011
Hi Bob,

Let's start again :

I want to set a minDate in a datepicker.

I used this code :
minDate:{date:'28-9-2011',format:'d-m-Y'}

placed in a Cstom DatePicker action.

BUT it does not work.

Can you please tell me what is wrong and how should I do ?

You can download a backup of my form in my previous message.
Max_admin 05 Oct, 2011
Hi dezi168,

Did you add a class for your datpicker box and then added the same class to the "custom datepicker" action ?

The order of the "show HTML" and "custom datepicker" actions may affect this as well, so please try to switch their order and see if this makes any difference, clearing your website/browser caches may be helpful as well.

Thank you for posting about the new date picker!🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dezi168 07 Oct, 2011
Hi Max,
Thanks very much for your reply.
I did specified a class.

I changed the order of the actions but I still does not work :
- 1st case : show html and after custom datepicker => result : datepicker is displayed but minDate is not taken into account (it is possible to select date anterior than minDate)
- 2nd case : custom datepicker and after show html => result : datepicker is not dusplayed and javascript error :
Uncaught TypeError: Cannot call method 'toString' of undefined, datepicker.js:670


I seriously think there is a bug.
Can you try to reproduce the bug with the backup file I have posted in a previous message ?

Best regards
dezi168 08 Oct, 2011
I propose the following changes to fix the bug in the 'datepicker.js' file :

change the line 91 :
		if (this.options.minDate && this.options.minDate.format) {

by :
		if (this.options.minDate && this.options.minDate.format) if (this.options.minDate.date) {

and change the line 94 :
		if (this.options.maxDate && this.options.maxDate.format) {

by :
		if (this.options.maxDate && this.options.maxDate.format) if (this.options.maxDate.date) {


Worked for me. But Max may find a better solution.
Hope will help other ones.
GreyHead 10 Oct, 2011
Hi dezi,

Thanks for the fix - as far sa I can see it's a symptom of the MonkeyPhysics datepicker not working properly with MooTools 1.3 - hence in Joomla! 1.6/1.7.

I have written a post here which gets ChronoForms to work with a later version of the DatePicker that does not have the same problems with MooTools 1.3.

I haven't tried all the bells and whistles yet but minDate and maxDate are working with fixed dates and I think that they can be used fairly easily with variable dates.

If you try it please do not use on a live site without testing and let me know about any problems you find.

I can't speak for Max but hopefully this or something very similar will find it's way into a forthcoming update of ChronoForms for Joomla! 1.6/1.7

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