Forum OpenACS Q&A: ad_form, ad_page_contract, and dates

Collapse
Posted by Janine Ohmer on
Ok, I know this subject has been discussed to death, but if there's a solution to this out there I couldn't find it in Google or in the code.  So here goes:

I've got a form element called birthday, which is a date (surprise! :).  My on_submit block redirects to another page, which of course uses ad_page_contract.  The date is coming through as birthday.month, birthday.day and birthday.year, so that's how I have to list them in ad_page_contract.  Then to refer to these values I have to use ${birthday.day}, etc, which does not work in the ADP, so I'm having to assign them to "normal" variables in order to use them. Yuck.

I'm guessing I should be "assembling" the date somehow in the on_submit block before I pass it on, so that it's recognizeable to ad_page_contract as a date, but how does one do that?

Thanks in advance....

Collapse
Posted by Dave Bauer on
Janine,

Use template::util::date::get_property to transform the date. In this case I would suggest ansi which will give you a usualy "YYYY-MM-DD" timestamp that is easy to pass around.

You should not need to access the individual elements of the date. In your case you would pass the value of "birthday" into that procedure. You could also pass the list in birthday to the next page as well.

Collapse
Posted by Janine Ohmer on
Thanks, Dave!  That put me on the right track.

For posterity's sake (or at least the next person who runs into this and finds this thread) I couldn't find an "ansi" parameter to get_property but the "display_date" worked just fine for what I needed to do.

Collapse
Posted by Janine Ohmer on
Actually I have another related question.  When I hit Submit on my form, it comes back to the original page, then the on_submit redirects the user away to the display page.  Because of the redirect I end up having to use export_vars to put all the form values in the URL.  I don't like this, but I searched for examples of a better way to do it and this is what I saw being done consistently. Is this really the right way to do it?  The URL gets long and ugly pretty fast.