Kay lives here

working with the web

ColdFusion_icon120px-XML_icon.svg

CFCalendar and XML CFFORM — It’s Alive!

grass

Peo­ple, lis­ten up: Mike Nimer rocks!

The other day I was whin­ing in my usual fash­ion about XML CFForm, which is awe­some, and CFCal­en­dar, which is also awe­some, and the fact that they don’t work together, which is most def­i­nitely not awesome.

Then “Magic Mike” Nimer left a com­ment — “I didn’t even real­ize this didn’t make it. I just sub­mit­ted a pri­or­ity A bug for this”. Wow, never say Macro­me­dia is not respon­sive! He also posted a workaround. It didn’t work at first — the value of the form wasn’t passed. After send­ing Mike an email he explained that the hid­den field which holds the value of the cal­en­dar wasn’t being gen­er­ated, but adding it man­u­ally (a workaround workaround, if you will) works smash­ingly. In Fire­fox (and pos­si­bly other browsers, didn’t test) the <cffor­mitem> needs a width, or you get ugly scroll­bars. But you were going to give it one any­way, 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 dis­abled, so it may be worth includ­ing a text field for date entry, per­haps in a noscript block, for that even­tu­al­ity if that is a concern.

Comments are closed.