template::widget::select_locales (public)

 template::widget::select_locales element_reference tag_attributes

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

Generate a select widget for locales. We need a custom widget for this one case because accessibility standards require us to put out a "lang" attribute if the text is not in the same language as the rest of the page.

Parameters:
element_reference
tag_attributes

Partial Call Graph (max 5 caller/called nodes):
%3 test_locale_select_widget locale_select_widget (test acs-lang) template::widget::select_locales template::widget::select_locales test_locale_select_widget->template::widget::select_locales template::util::list_to_lookup template::util::list_to_lookup (public) template::widget::select_locales->template::util::list_to_lookup

Testcases:
locale_select_widget
Source code:

    upvar $element_reference element

    if { [info exists element(html)] } {
        array set attributes $element(html)
    }
    if { [info exists element(values)] } {
         template::util::list_to_lookup $element(values) values
    }
    array set attributes $tag_attributes

    if { $element(mode) ne "edit" } {
        set selected_list [list]

        foreach option $element(options) {

            lassign $option label value

            if { [info exists values($value)] } {
                lappend selected_list $label
                append output "<input type=\"hidden\" name=\"$element(name)\" value=\"[ns_quotehtml $value]\">"
            }
        }

        append output [join $selected_list ", "]

    } else {

        append output "<select name=\"$element(name)\" id=\"$element(name)\" "

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

        foreach option $element(options) {

            lassign $option label value

            set value [ns_quotehtml $value]
            append output " <option lang=\"[string range $value 0 1]\" value=\"$value\""
            if { [info exists values($value)] } {
                append output " selected=\"selected\""
            }

            append output ">$label</option>\n"
        }
        append output "</select>"
    }

    return $output
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: