form — a Tcl command object for creating HTML forms
form_name
?-option1 value_1
? ?-option2 value_2
? ?...?
creates and returns a new Tcl command named form_name
.
form_name
?default_values
?URL
?
Form object commands follow the usual syntax of Tcl commands with a ?subcommand
? argument playing the
role of a switch among various functionalities of the command. Form objects also need the ?name
? parameter
which is to become the value of the 'name' attribute in an input field. This argument is the key that has to be
used by the server-side script to retrieve the input field value.
value1
? ?-option2 value2
? ?...?Options passed to a subcommand are copied into the tag as attribute="value" pairs. Some subcommands (e.g. form, radiobuttons and checkboxes) treat specific options in a way that fits the specific organization and function of these fields.
Exceptions to this general syntax are the field and end subcommands. field is an abstract input field creation method and requires an additional parameter specifiyng the type of field to create. Every concrete input field generation command uses this subcommand internally to print the final html.
get | post
? ?-name form_name
? ?-defaults default_values
? ?-action URL
? ?args?response
form myform -defaults response -method get -name formname myform start myform text text_entry -size 20 myform select option_selected -values {opt1 opt2 opt3 opt4} myform submit submit -value Search myform end
form_name
?default_values
?URL
?type
? and ?name
?,
including any default key-value pairs defined for this field
type and optional key-value pairs included with the statement
values
? ?-labels labels
? ?args?values_list
?labels_list
?form myform -defaults response -method get -name formname myform start myform text text_entry -size 20 myform radiobuttons fruit -values {big medium small} \ -labels {Watermelon Orange Strawberry} \ -class myradiobclass myform submit submit -value Search myform end
<input type="radio" name="fruit" class="myradiobclass" value="big" />Watermelon <input type="radio" name="fruit" class="myradiobclass" value="medium" />Orange <input type="radio" name="fruit" class="myradiobclass" value="small" />Strawberry
response
array has a variable for the name 'fruit' the corresponding
radiobutton field is automatically checked. The options ?values? and ?labels?
are used internally and don't get into the tag attributes. If a ?labels?
option is not given, labels are assigned using the ?values? list.
label
? ?-value value
? ?args?form myform -defaults response -method get -name formname -action <form_url> myform start myform checkbox options -value opt1 -label "Option 1" myform checkbox options -value opt2 -label "Option 2" myform checkbox options -value opt3 -label "Option 3" myform checkbox options -value opt4 -label "Option 4" myform submit save_tps -value "Send Options" myform end myform destroy
<form action="<form_url>" method="get" name="formname"> <input type="checkbox" name="options" id="autogen_1" label="Option 1" value="sopt1" /><label for="autogen_1">Option 1</label> <input type="checkbox" name="options" id="autogen_2" label="Option 2" value="sopt2" /><label for="autogen_2">Option 2</label> <input type="checkbox" name="options" id="autogen_3" label="Option 3" value="sopt3" /><label for="autogen_3">Option 3</label> <input type="checkbox" name="options" id="autogen_4" label="Option 4" value="sopt4" /><label for="autogen_4">Option 4</label> <input type="submit" name="submit" value="Send" /> </form>
labels_list
? ?-values values_list
? ?args?labels_list
? argument
values_list
?labels_list
?form myform -defaults response -method post -action <form_url> myform start myform checkboxes options -values {opt1 opt2 opt3 opt4} -labels {"Option 1" "Option 2" "Option 3" "Option 4"} myform submit save_tps -value "Send Options" myform end myform destroy
<form action="<form_url>" method="post"> <input type="checkbox" name="options" id="autogen_1" label="Option 1" value="opt1" /><label for="autogen_1">Option 1</label> <input type="checkbox" name="options" id="autogen_2" label="Option 2" value="opt2" /><label for="autogen_2">Option 2</label> <input type="checkbox" name="options" id="autogen_3" label="Option 3" value="opt3" /><label for="autogen_3">Option 3</label> <input type="checkbox" name="options" id="autogen_4" label="Option 4" value="opt4" /><label for="autogen_4">Option 4</label> <input type="submit" name="save_tps" value="Send Options" /> </form>
form myform -defaults response -method get -name feedsearch myform start myform submit submit -value Search
<form...> <input type="submit" name="submit" value="Search" /> </form>