Forum OpenACS Q&A: ad_forms q: filling with data for edit only

Hallo all,
I am trying to build a small ad_form for editing only data of one table:

1) Do I HAVE to use the
element_name:key(sequence_name)

Since this is a help table, I have to be absolutelly sure that it will never thy to add a record there.

2) I am doing at the moment:

ad_form -name update_details -select_query_name user_information  -form {
...
...
    } -edit_data {
...
...
}

Even though the "user_information" is a valid query, when the form is being "called", it has no data inside.

Thanks
Koyan

Collapse
Posted by Chris Davies on
ad_page_contract {
        Modify Category
} {
    catid:integer
}

ad_form -name modcat -form {

    catid:key
    {path:text(select),optional
      {options {{"" ""} [db_list_of_lists get_categories "select path from todip_categories order by path,pathend"]}}
      {label "Parent Category"}
    }
    {pathend:text
        {label "Name of Category"}
    }
    {descr:text,optional
        {label "Category Description"}
    }
    {allowsub:boolean(select)
        {options {{"Yes" "Y"} {"No" "N"}}}
        {label "Allow Submissions in this Category"}
    }
} -select_query "select *,path from todip_categories where catid=:catid" -edit_data {
db_dml link_edit "
update todip_categories set path=:path,pathend=:pathend,allowsub=:allowsub,
descr=:descr where catid=:catid"

} -after_submit {
ad_returnredirect "index"
}

that is a working adform that I use that reads the data

I believe in the top where I specify catid as integer, that makes it a required field (optional is not the default if I recall)  And, as long as there is no -new-data section, they shouldn't be able to add a record.

This form does pull the data from the SQL -- not very pretty, but it was easier than including a few other files.

Thank you very much.
It works fine now.