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

Partial Call Graph (max 5 caller/called nodes):
%3 template::widget::attachment template::widget::attachment (public) template::widget::input template::widget::input template::widget::attachment->template::widget::input template::widget::button template::widget::button (public) template::widget::button->template::widget::input template::widget::checkbox template::widget::checkbox (public) template::widget::checkbox->template::widget::input template::widget::checkbox_text template::widget::checkbox_text (public) template::widget::checkbox_text->template::widget::input template::widget::color template::widget::color (public) template::widget::color->template::widget::input template::widget::hidden template::widget::hidden (public) template::widget::input->template::widget::hidden

Testcases:
No testcase defined.
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:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-templating/tcl/widget-procs.xql

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