1
mackingspain
how to turn off showcalendar / displaycalendar call in forms?

Greetings -

I'm using Formulize with XOOPS 2.0.15, PHP Version 4.4.4, and MySQL Version 4.1.21 and have a problem when I use date boxes in forms. A button like this:

<input type='reset' value=' ... ' onclick='return showCalendar("ele_45");'>

is put next to each date field which seems designed to bring up a visual calendar using javascript. In my site, however, the button does not bring up the box and instead resets all of the fields the user has already filled in on the form. The guilty tag seems to be:

<input type='reset' value=' ... ' onclick='return showCalendar("ele_45");'>

element 45 is the date I'm using there, btw

I have warned users about this but it's just too tempting for them. I'm wondering if there's a hack to just get rid of the showcalendar box call for forms altogether. The most most relevant error I get on the page in debug mode is:

Warning: Missing argument 8 for displaycalendar() in file /modules/formulize/include/calendardisplay.php line 62

If I understand the message correctly, element 8 is $hidden, but I'm not sure where it's set.

It might be something particular to my site, but I have tried different browsers and turning off pop-up blockers.

2
jegelstaff
Re: how to turn off showcalendar / displaycalendar call in forms?

Hello,

I don't think the problem you're having with the showCalendar javascript function is related to the notice about the displayCalendar PHP function.

Have you installed the datebox patch that we distribute with Formulize? It changes the behaviour of XOOPS dateboxes slightly.

What exactly happens when users click the button? All fields in the form go blank? Or just calendar fields? What version of Formulize are you using?

--Julian
Technical Architect - Freeform Solutions
Formulize - custom registration forms, ad hoc forms and reports

3
mackingspain
Re: how to turn off showcalendar / displaycalendar call in forms?

Thanks for getting back to me - I should have mentioned that I'm working with Formulize 2.2RC1. The files I have seem to be identical to the ones in the patch.

The behavior of the date box & button is as follows:

- the form appears with today's date already filled in

- when the button is clicked, all fields revert to the default value set when the page was first opened. text fields are blank, option boxes are reset, yes/no boxes are set to the default setting, and date boxes are reset to today's date.

I created another test form as an experiment and saw the same behavior from the date box in that form. I tried formatting the date differently (mm-dd-YYYY for example) but saw the same behavior.

4
jegelstaff
Re: how to turn off showcalendar / displaycalendar call in forms?

What browser are you using? I think this is a bug in the HTML that is only rearing it's head in a particular browser, maybe IE 7?

Here's the thing, the calendar '...' buttons are listed as "type=reset", and the behaviour you're describing is exactly what you'd expect a reset button to do in a form. But the onclick event should (and normally does) override the behaviour of the reset button. Instead, the button simply does whatever the javascript function returns, which should be the typical calendar that we know and love.

However, in your case, the javascript is failing. This could be because your site has a problem with accessing the javascript function that shows the calendar (did you put the <{$calendarjs}> smarty tag into your main page template when you installed the datebox patch?).

Or it could be that the browser you are using is deciding that the 'reset' status of the button should override whatever onclick events the button has.

Or both.

So the first thing to do is make sure the javascript function is available. So make sure that <{$calendarjs}> is in your main page template. Right before the <title> tag is recommended.

If you do that, check the page source after going to the form, to make sure the change is picked up. You should have a lot of javascript code near the top, including a line like this:

function showCalendar(id) {

If you don't have that even after making the change, make sure your templates are being read properly and you don't have any cached or compiled templates or other files getting in the way. Check the FAQ on this site for help making sure changes are reflected in your live site.

If you do have that javascript in the page now, and you click the button and you still get the reset behaviour and not the calendar behaviour, then you need to fix that HTML bug in the date select box, which should never have been written that way in the first place in my opinion, I'm sorry we didn't correct it when we made our datebox patch.

Anyway, go to class/xoopsform/formtextdateselect.php and change the text near the bottom that says type='reset' to type='button'.

If you do that, and then try to click the calendar button, I sure hope it works!

Make sense?

--Julian
Technical Architect - Freeform Solutions
Formulize - custom registration forms, ad hoc forms and reports

5
mackingspain
and the answer is . . .

I had the tag in the wrong place. I'd put the <{$calendarjs}> tag <b>after</b> TITLE in the templates page, and as you say here, it needs to be <b>before</b>.

I'd installed the patch from the <a href="http://sourceforge.net/tracker/?func=detail&aid=1077123&group_id=41586&atid=430842">Sourceforge</a> instructions, which asks for the tag to go after TITLE, but I wasn't able to get functionality out of this until I followed the instructions in this post and moved the tag up.

Thanks again for your help!

6
jegelstaff
Re: and the answer is . . .

Odd, maybe you had a typo. It shouldn't matter if it's before or after the title (it was before the title in a site I checked while writing that post). In the Formulize readme, we say put it after the title. Javascript should be read by the browser no matter where it is, as long as it's inside script tags, inside the html tags. Anyway, I'm glad it's working now!

--Julian
Technical Architect - Freeform Solutions
Formulize - custom registration forms, ad hoc forms and reports