xowiki::FormPage instproc set_form_data (public)

 <instance of xowiki::FormPage[i]> set_form_data form_fields

Defined in /var/www/openacs.org/packages/xowiki/tcl/xowiki-www-procs.tcl

Store the instance attributes or default values into the form via set_form_value. This function iterates over the provided form-fields and checks, if these are known fields in the current form. These known field names are defined via the method "field_names" that extracts these names from a form. If one wants to load all values from an FormPage into the provided form-fields, use method "load_values_into_form_fields" instead.

Parameters:
form_fields (required)

Testcases:
create_form_with_form_instance
Source code:
::xo::require_html_procs

foreach f $form_fields {
  set att [$f name]
  # just handle fields of the form entry
  if {![dict exists ${:__field_in_form} $att]} continue
  #:msg "set form_value to form-field $att [dict exists ${:instance_attributes} $att]"
  if {[dict exists ${:instance_attributes} $att]} {
    #:msg "my set_form_value from ia $att '[dict get ${:instance_attributes} $att]', external='[$f convert_to_external [dict get ${:instance_attributes} $att]]' f.value=[$f value]"
    :set_form_value $att [$f convert_to_external [dict get ${:instance_attributes} $att]]
  } else {
    # do we have a value in the form? If yes, keep it.
    set form_value [:get_form_value $att]
    #:msg "no instance attribute, set form_value $att '[$f value]' form_value=$form_value"
    if {$att eq ""} {
      # we have no instance attributes, use the default value from the form field
      :set_form_value $att [$f convert_to_external [$f value]]
    }
  }
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: