Forum OpenACS Development: Re: template::form::generate

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