Forum OpenACS Development: template::form::generate

Collapse
Posted by Barry Books on
I'm trying to use template::form::generate but I'm having problems I wrote this test page
        ad_form -name cal_item -form {   
                {title:text(text)
                        {label "title"}
                        {html {size 60} maxlength 255}
                }
                {date:date
                        {label "date"}
                }
        }

        set doc [template::form::generate cal_item]
with the following adp page
<formtemplate id=cal_item> </formtemplate>

@doc;noquote@
The formtemplate tag works fine but doc does not have the visible input tags. The hidden tags and the button are there as well as the titles. I noticed this function is marked private and I cannot find any place in the source tree that calls it. I'm running 5.0 HEAD so that could be the reason it does not work. Any ideas?
Collapse
Posted by Lars Pind on
Why do you want to do this?

If you want to see the code output by the form, try requesting your page with a .cmp extension, which will provide you with the compiled version of the template.

This requires that you use the site-map to set a parameter on acs-templating to enable it and restart your server.

/Lars

Collapse
Posted by Barry Books on
I need to build a form in a page that outputs javascript instead of HTML. I did the request page from page trick already but it's too slow. I might be able to use the templating system as it but I can't seem to set the mime type to text/javascript on the return page. This function does exactly what I need except it does not appear to work.

I read the docs, ad_form seems a little complicated and I suspect it's an upvar problem. I guess I'll try and track it down. Any reason this function is declared private?

Collapse
Posted by Barry Books on
never mind I got the templating system working. It was the noquote stuff messing me up. I guess I'll get used to it.
Collapse
Posted by Vincent Tam on
Hi, I am new to OpenACS, I got problems with using ad_form. Please help me.

1) I got a psql table with the following attribute:
(ev_id, ev_date, ev_text) and i want to use ad_form for adding and updating the table. However I got problem dealing with the psql type "date",

ad_form -name myform -form {
  ev_id: key
  {ev_date:date {lable "Date"}}
  {ev_text:text(textarea) {label "text"}}
}

this will nicely print out widgets for inputing date. however, how can i put the default value when EDITING data? ie. if I used a normal select query in the -select_query option of ad form:
-select query {
  select ev_date, ev_text where ev_id = :ev_id
}

then one of the boxes in the date widgets is filled with the entire date value, with the others left blanked. Any hints?

2) in the -new_data option, i want to use queries in the xql file, but how can i get the "date" value from the date widgets? it returns a tcl list, but i don't know how to interpolate the list value in the xql file, therefore at the moment i am using the following for -new_data:
-new_data {
db_1row dummy \
"select myev__new(null, '[lindex $ev_date 0] [lindex $ev_date 1] [lindex $ev_date 2]', :ev_text, null, :user_id,null,null)"
}
but it would be good if someone can give me a hint on how i am going to use the list's values in the xql file.

Thanks

Collapse
Posted by Vincent Tam on
Hi, I am new to OpenACS, I got problems with using ad_form. Please help me.

1) I got a psql table with the following attribute:
(ev_id, ev_date, ev_text) and i want to use ad_form for adding and updating the table. However I got problem dealing with the psql type "date",

ad_form -name myform -form {
  ev_id: key
  {ev_date:date {lable "Date"}}
  {ev_text:text(textarea) {label "text"}}
}

this will nicely print out widgets for inputing date. however, how can i put the default value when EDITING data? ie. if I used a normal select query in the -select_query option of ad form:
-select query {
  select ev_date, ev_text where ev_id = :ev_id
}

then one of the boxes in the date widgets is filled with the entire date value, with the others left blanked. Any hints?

2) in the -new_data option, i want to use queries in the xql file, but how can i get the "date" value from the date widgets? it returns a tcl list, but i don't know how to interpolate the list value in the xql file, therefore at the moment i am using the following for -new_data:
-new_data {
db_1row dummy \
"select myev__new(null, '[lindex $ev_date 0] [lindex $ev_date 1] [lindex $ev_date 2]', :ev_text, null, :user_id,null,null)"
}
but it would be good if someone can give me a hint on how i am going to use the list's values in the xql file.

Thanks

Collapse
Posted by Jade Rubick on
Vincent, this might help a little:

http://rubick.com:8002/openacs/ad_form

Collapse
Posted by Vincent Tam on
Thanks, I got it :)