util::html::get_form_vars (public)

 util::html::get_form_vars -form form

Defined in packages/acs-tcl/tcl/html-procs.tcl

Read vars from a form structure as that coming out from util::html::get_form.

Switches:
-form
(required)
Form structure
Returns:
var specification in a form suitable for the vars argument of proc export_vars.

Partial Call Graph (max 5 caller/called nodes):
%3 util::http::cookie_auth util::http::cookie_auth (public) util::html::get_form_vars util::html::get_form_vars util::http::cookie_auth->util::html::get_form_vars

Testcases:
No testcase defined.
Source code:
    set varDict ""
    #
    # Extract value from every field
    #
    foreach field [dict get $form fields] {
        set attributes [dict get $field attributes]
        # no name, no variable
        if {![dict exists $attributes name]
            || [dict get $attributes name] eq ""} {
            continue
        }
        set name [dict get $attributes name]
        set tag  [dict get $field tag]
        switch -- $tag {
            "input" {
                if {[dict exists $attributes value]} {
                    dict lappend varDict $name [dict get $attributes value]
                }
            }
            "textarea" {
                if {[info exists fld(value)]} {
                    dict lappend varDict $name [dict get $field value]
                }
            }
            "select" {
                foreach option [dict get $field options] {
                    set oAttributes [dict get $option attributes]
                    if {[dict exists $oAttributes selected]} {
                        dict lappend varDict $name [dict get $oAttributes value]
                    }
                }
            }
        }
    }
    
    # Now varDict must be translated in export_vars form
    set vars [list]
    foreach {name value} $varDict {
      # Multiple values must be specified 
      # with the :multiple modifier
      if {[llength $value] > 1} {
          set name ${name}:multiple
      # Single values must be extracted 
      # from the list
      } else {
          set value [lindex $value 0]
      }
      # Formfield's name can contain colons,
      # I need to escape them.
      regsub -all -- {:} $name {\:} name
      lappend vars [list $name $value]
    }
    
    return $vars
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: