Web Forms
Created by Rocael Hernández Rizzardini, last modified by Gustaf Neumann 22 Mar 2019, at 11:21 PM
Use ad_form to create HTML forms. If you work on a page that does not, convert it to use ad_form.
You can grep the toolkit under /packages and see many examples.
Ad_form can handle many of your possible interactions with the system, such as normal tasks as add and edit data, validate entry form data, etc.
Additional information here:
Use the following in the tcl part of a page to limit access to page requests via post.. to reduce vulnerability to url hack and insertion attacks from web:
if { [ad_conn method] ne "POST" } { ad_script_abort }
Grouping elements into sections using ad_form
The {-section} list allows to group the subsequent elements (until the next section declaration) into a section. {-section} accepts 4 properties:
{-section section_id {legendtext $legendstring} {legend {name value name value ... name value}} {fieldset {name value name value ... name value}} }
where:
- section_id: a string to identify the section (mandatory)
- legendtext (optional) a string for the legend of the fieldset (section)
- legend (optional) a list of name value pairs attributes for the LEGEND tag
- fieldset (optional) a list of name value pairs attributes for the FIELDSET tag
Example
ad_form \ -name "your_zen_level" \ -method post -html {enctype multipart/form-data class margin-form} \ -fieldset {{title "T1" class "C1"} "This really works!!"} \ -form { # Start section 1 {-section "sec1" {legendtext "Section Title I"} {legend {class myClass id myId}}} {zen_comment:text(comment)\ {label "template::widget::comment"}\ {value "Please enter your comments."}\ {html {rows 7 cols 50}}} {zen_file:text(file),optional\ {label "template::widget::file"}} # Start section2 {-section "sec2" {legendtext "Section Title II"} {fieldset {class myclass}}} {zen_multiselect:text(multiselect)\ {label "template::widget::multiselect"}\ {options {"mark" "emma" "avni" "carl" "don"}}} # Unset the section. subsequent elements will not be in any section. {-section ""} {zen_text:text(text),optional,nospell\ {label "template::widget::text"}\ {help_text {"Your identification tag number"}}} {zen_textarea:text(textarea),optional,nospell\ {label "template::widget::textarea"}\ {help_text {"Please describe your desired state of being"}}\ {html {rows 7 cols 50}}} }