Kay lives here

working with the web

CFCalendar and XML CFFORM – It’s Alive!

People, listen up: Mike Nimer rocks!

The other day I was whining in my usual fashion about XML CFForm, which is awesome, and CFCalendar, which is also awesome, and the fact that they don’t work together, which is most definitely not awesome.

Then “Magic Mike” Nimer left a comment – “I didn’t even realize this didn’t make it. I just submitted a priority A bug for this”. Wow, never say Macromedia is not responsive! He also posted a workaround. It didn’t work at first – the value of the form wasn’t passed. After sending Mike an email he explained that the hidden field which holds the value of the calendar wasn’t being generated, but adding it manually (a workaround workaround, if you will) works smashingly. In Firefox (and possibly other browsers, didn’t test) the <cfformitem> needs a width, or you get ugly scrollbars. But you were going to give it one anyway, weren’t you?

So here’s a repost of Mike’s code:

<cfform format="xml" skin="basic">

    <cfsavecontent variable="cal"><cfcalendar name="foo"></cfsavecontent>

    <cfoutput>

        <!--- :: If you want to handle the calendar with a custom rule :: --->

        <cfformitem type="calendar">#cal#</cfformitem>

        <!--- :: Or this. :: --->

        <cfformitem type="html">#cal#</cfformitem>

        <!--- :: add the hidden field :: --->

        <cfinput type="hidden" name="foo">

    </cfoutput>

</cfform>

Note that it will not work if JavaScript is disabled, so it may be worth including a text field for date entry, perhaps in a noscript block, for that eventuality if that is a concern.

Comments are closed.