template::widget::input (public)

 template::widget::input type element_reference tag_attributes

Defined in packages/acs-templating/tcl/widget-procs.tcl

General proc used by a wide variety of widgets to output input HTML tags.

Parameters:
type - The type of widget (checkbox, radio, text etc)
element_reference - Reference variable to the form element
tag_attributes - HTML attributes to hang on the input tag
Returns:
Form HTML for widget
Source code:

    upvar $element_reference element

    if { [info exists element(html)] } {
        array set attributes $element(html)
    }

    array set attributes $tag_attributes

    if { ( $type eq "checkbox" || $type eq "radio" ) && [info exists element(value)] } {
        # This can be used in the form template in a <label for="id">...</label> tag.
        set attributes(id) "$element(form_id):elements:$element(name):$element(value)"
    } elseif$type in {"password" "text" "button" "file" }} { 
	set attributes(id) "$element(name)" 
    }

    # Handle display mode of visible normal form elements, i.e. not hidden, not submit, not button, not clear
    if { $element(mode) ne "edit" && $type ni { hidden submit button clear checkbox radio } } {
        set output ""
        if { [info exists element(value)] } {
            append output [ns_quotehtml $element(value)]
            append output [subst {<input type="hidden" name="$element(name)" value="[ns_quotehtml $element(value)]">}]
        }
    } else {
        set output [subst {<input type="$type" name="$element(name)"}]

        if { $element(mode) ne "edit" && $type ni { hidden submit button clear } } {
            append output " disabled"
        } elseif { ![info exists element(optional)] && $type ni { hidden submit button clear } } {
            append output " required"
	}

        if { [info exists element(value)] } {
            append output [subst { value="[ns_quotehtml $element(value)]"}]
        } 

        foreach name [array names attributes] {
            if {$attributes($name) eq {}} {
                append output $name"
            } else {
                append output [subst { $name="$attributes($name)"}]
            }
        }

        if { [info exists element(maxlength)] } {
            append output [subst { maxlength="$element(maxlength)"}]
        }

        append output " >"

    }

    return $output
XQL Not present:
Generic
PostgreSQL XQL file:
packages/acs-templating/tcl/widget-procs-postgresql.xql

Oracle XQL file:
packages/acs-templating/tcl/widget-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: