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

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.