template::element::get_opts (private)

 template::element::get_opts [ -widget widget ] [ -datatype datatype ] \
    [ -label label ] [ -html html ] [ -maxlength maxlength ] \
    [ -options options ] [ -fieldset fieldset ] [ -legend legend ] \
    [ -legendtext legendtext ] [ -value value ] [ -values values ] \
    [ -validate validate ] [ -sign ] [ -help_text help_text ] \
    [ -help ] [ -optional ] [ -mode mode ] [ -nospell ] [ -noquote ] \
    [ -before_html before_html ] [ -after_html after_html ] \
    [ -display_value display_value ] [ -multiple ] [ -format format ] \
    [ -section section ] [ -htmlarea_p htmlarea_p ] [ args... ]

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

template::element::create syntax requires first two non-positional arguments (form and element name), then a set of named-argument flags to transform into options. This is not the native Tcl syntax, where named-arguments come before unnamed ones. To use native Tcl argument parsing for remaining flags, we create this internal utility.

Switches:
-widget
(optional)
-datatype
(optional)
-label
(optional)
-html
(optional)
-maxlength
(optional)
-options
(optional)
-fieldset
(optional)
-legend
(optional)
-legendtext
(optional)
-value
(optional)
-values
(optional)
-validate
(optional)
-sign
(boolean) (optional)
-help_text
(optional)
-help
(boolean) (optional)
-optional
(boolean) (optional)
-mode
(optional)
-nospell
(boolean) (optional)
-noquote
(boolean) (optional)
-before_html
(optional)
-after_html
(optional)
-display_value
(optional)
-multiple
(boolean) (optional)
-format
(optional)
-section
(optional)
-htmlarea_p
(optional)
Returns:
a dict of options
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::element::create template::element::create (public) template::element::get_opts template::element::get_opts template::element::create->template::element::get_opts ad_log ad_log (public) template::element::get_opts->ad_log template::element::options template::element::options (private) template::element::get_opts->template::element::options template::element::validate template::element::validate (private) template::element::get_opts->template::element::validate

Testcases:
No testcase defined.
Source code:
    set opts [list]
    #
    ## These are the documented options we expect in widgets. We know
    ## exactly which are key value pairs and which ones are one-valued
    ## booleans
    #
    set flags {
        widget
        datatype
        label
        html
        maxlength
        options
        fieldset
        legend
        legendtext
        value
        values
        validate
        help_text
        mode
        before_html
        after_html
        display_value
        format
        section
        htmlarea_p
    }
    set booleans {
        sign
        help
        optional
        nospell
        noquote
        multiple
    }
    foreach flag $flags {
        if {[info exists $flag]} {
            dict set opts $flag [set $flag]
        }
    }
    foreach boolean $booleans {
        if {[set ${boolean}_p]} {
            dict set opts $boolean 1
        }
    }
    #
    ## If additional args are found, we might deal with custom options
    ## from user-defined widgets. We treat all of those as name value
    ## pairs.
    ## TODO: one could consider having custom argument parsers for
    ## those widgets.
    #
    while {[llength $args] > 0} {
        set arg [string range [lindex $args 0] 1 end]
        if {![dict exists $opts $arg]} {
            # Collect this name value pair as a custom option
            set name $arg
            set value [lindex $args 1]
            dict set opts $name $value
            #ad_log notice "Collecting custom option for template::element name=$name, value=$value"
        }
        if {$arg in $booleans} {
            # When this is one of the known booleans, just skip one
            # argument.
            set args [lrange $args 1 end]
        } else {
            # In all other cases, skip 2 arguments (treat options as
            # name value pairs).
            set args [lrange $args 2 end]
        }
    }
    # After parsing of custom arguments, the list should be
    # empty. That we still have stuff in there means something is not
    # ok with the element specs.
    if {[llength $args] > 0} {
        ad_log warning "Ignoring undocumented args for template::element $args"
    }
    return $opts
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: