::xowiki::formfield::FormField ::xowiki::formfield::FormField → fc_decode → fc_encode json_value ::xo::tdom::Object ::xo::tdom::Object ::xowiki::formfield::FormField->::xo::tdom::Object ::xowiki::formfield::CompoundField ::xowiki::formfield::CompoundField get_named_sub_component_value json_value ::xowiki::formfield::CompoundField->::xowiki::formfield::FormField ::xowiki::formfield::repeatContainer ::xowiki::formfield::repeatContainer json_value ::xowiki::formfield::repeatContainer->::xowiki::formfield::CompoundField ::xowiki::formfield::regression_test_mycompound ::xowiki::formfield::regression_test_mycompound ::xowiki::formfield::regression_test_mycompound->::xowiki::formfield::CompoundField ::xowiki::formfield::text_fields ::xowiki::formfield::text_fields ::xowiki::formfield::text_fields->::xowiki::formfield::CompoundField ::xowiki::formfield::ShuffleField ::xowiki::formfield::ShuffleField ::xowiki::formfield::text_fields->::xowiki::formfield::ShuffleField ::xowiki::formfield::regression_test_compound_with_repeat2 ::xowiki::formfield::regression_test_compound_with_repeat2 ::xowiki::formfield::regression_test_compound_with_repeat2->::xowiki::formfield::CompoundField ::xowiki::formfield::mc_exercise ::xowiki::formfield::mc_exercise ::xowiki::formfield::mc_exercise->::xowiki::formfield::CompoundField ::xowiki::formfield::date ::xowiki::formfield::date ::xowiki::formfield::date->::xowiki::formfield::CompoundField ::xowiki::formfield::CalendarField ::xowiki::formfield::CalendarField ::xowiki::formfield::CalendarField->::xowiki::formfield::CompoundField ::xowiki::formfield::repeattest ::xowiki::formfield::repeattest ::xowiki::formfield::repeattest->::xowiki::formfield::CompoundField ::xowiki::formfield::mc_alternative ::xowiki::formfield::mc_alternative ::xowiki::formfield::mc_alternative->::xowiki::formfield::CompoundField ::xowiki::formfield::FormGeneratorField ::xowiki::formfield::FormGeneratorField ::xowiki::formfield::FormGeneratorField->::xowiki::formfield::CompoundField ::xowiki::formfield::regression_test_compound_with_repeat ::xowiki::formfield::regression_test_compound_with_repeat ::xowiki::formfield::regression_test_compound_with_repeat->::xowiki::formfield::CompoundField ::xowiki::formfield::regression_test_compound_numeric ::xowiki::formfield::regression_test_compound_numeric ::xowiki::formfield::regression_test_compound_numeric->::xowiki::formfield::CompoundField ::xowiki::formfield::comp_correct_when ::xowiki::formfield::comp_correct_when ::xowiki::formfield::comp_correct_when->::xowiki::formfield::CompoundField ::xowiki::formfield::time_span ::xowiki::formfield::time_span ::xowiki::formfield::time_span->::xowiki::formfield::CalendarField ::xowiki::formfield::event ::xowiki::formfield::event ::xowiki::formfield::event->::xowiki::formfield::CalendarField ::xowiki::formfield::TestItemField ::xowiki::formfield::TestItemField ::xowiki::formfield::TestItemField->::xowiki::formfield::FormGeneratorField

Class ::xowiki::formfield::CompoundField

::xowiki::formfield::CompoundField[i] create ... \
           [ -CSSclass (default "compound-field") ] \
           [ -components (default "") ]

Defined in

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::FormField[i]
  • subclass: ::xowiki::formfield::repeatContainer[i], ::xowiki::formfield::regression_test_mycompound[i], ::xowiki::formfield::text_fields[i], ::xowiki::formfield::regression_test_compound_with_repeat2[i], ::xowiki::formfield::mc_exercise[i], ::xowiki::formfield::date[i], ::xowiki::formfield::CalendarField[i], ::xowiki::formfield::repeattest[i], ::xowiki::formfield::mc_alternative[i], ::xowiki::formfield::FormGeneratorField[i], ::xowiki::formfield::regression_test_compound_with_repeat[i], ::xowiki::formfield::regression_test_compound_numeric[i], ::xowiki::formfield::comp_correct_when[i]
::xotcl::Class create ::xowiki::formfield::CompoundField \
     -superclass ::xowiki::formfield::FormField

Methods (to be applied on instances)

  • get_named_sub_component_value (scripted, public)

     <instance of xowiki::formfield::CompoundField[i]> get_named_sub_component_value \
        [ -from_repeat ] [ -default default ] args [ args... ]

    Return the value of a named subcomponent. When the named subcomponent is a repeated item, and the value of the 0th element of the repeat (the template element) is omitted from the returned value.

    Switches:
    -from_repeat (optional)
    skip template element from repeated values
    -default (optional)
    default value, when component is not found
    Parameters:
    args (required)
    space separated path of elements names in a potentially nested component structure (similar to dict)

    Testcases:
    create_test_items
    if {[:exists_named_sub_component {*}$args]} {
      set result [[:get_named_sub_component {*}$args] value]
      if {$from_repeat} {
        if {[lindex [split [lindex $result 0] .] end] eq "0"} {
          set result [lrange $result 2 end]
        }
      }
    } else {
      set result $default
    }
    return $result
  • json_value (scripted, public)

     <instance of xowiki::formfield::CompoundField[i]> json_value value

    Recursively export stored components as a JSON object. Strip the containing field's name prefix from component keys, omit transient components, and retain unknown components as strings. Invalid legacy values that are not dictionaries remain strings.

    Parameters:
    value (required)
    Stored dictionary of fully qualified component names and values.
    Returns:
    Two-element ns_json type/payload pair; object payloads contain triples.

    Testcases:
    No testcase defined.
    if {[catch {dict size $value}]} {
      return [list string $value]
    }
    set entries {}
    dict for {name v} $value {
      set key $name
      set prefix ${:name}.
      if {[string first $prefix $name] == 0} {
        set key [string range $name [string length $prefix] end]
      }
      if {[string match __* $key]} {
        continue
      }
      set type string
      set payload $v
      foreach c ${:components} {
        if {[$c name] eq $name} {
          lassign [$c json_value $v] type payload
          break
        }
      }
      lappend entries $key $type $payload
    }
    return [list object $entries]