- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::formfield::CompoundField
::xowiki::formfield::CompoundFieldcreate ... \
[ -CSSclass (default "compound-field") ] \
[ -components (default "") ]
Defined in
Class Relations
- class: ::xotcl::Class
- superclass: ::xowiki::formfield::FormField
- subclass: ::xowiki::formfield::repeatContainer
, ::xowiki::formfield::regression_test_mycompound
, ::xowiki::formfield::text_fields
, ::xowiki::formfield::regression_test_compound_with_repeat2
, ::xowiki::formfield::mc_exercise
, ::xowiki::formfield::date
, ::xowiki::formfield::CalendarField
, ::xowiki::formfield::repeattest
, ::xowiki::formfield::mc_alternative
, ::xowiki::formfield::FormGeneratorField
, ::xowiki::formfield::regression_test_compound_with_repeat
, ::xowiki::formfield::regression_test_compound_numeric
, ::xowiki::formfield::comp_correct_when
::xotcl::Class create ::xowiki::formfield::CompoundField \ -superclass ::xowiki::formfield::FormFieldMethods (to be applied on instances)
get_named_sub_component_value (scripted, public)
<instance of xowiki::formfield::CompoundField> 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 $resultjson_value (scripted, public)
<instance of xowiki::formfield::CompoundField> 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]
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)