form-field-procs.tcl

XoWiki - form fields

This file defines the following Objects and Classes: ::xowiki::formfield::FormField[i], ::xowiki::formfield::localized_text[i], ::xowiki::formfield::range[i], ::xowiki::formfield::numeric[i], ::xowiki::formfield::localized_richtext[i], ::xowiki::formfield::ShuffleField[i], ::xowiki::formfield::text_fields[i], ::xowiki::formfield::candidate_box_select[i], ::xowiki::formfield::FormField[i], ::xowiki::formfield::localized_text[i], ::xowiki::formfield::range[i], ::xowiki::formfield::numeric[i], ::xowiki::formfield::localized_richtext[i], ::xowiki::formfield::ShuffleField[i], ::xowiki::formfield::text_fields[i], ::xowiki::formfield::candidate_box_select[i]

Location:
packages/xowiki/tcl/form-field-procs.tcl
Created:
2007-06-22
Author:
Gustaf Neumann
CVS Identification:
$Id: form-field-procs.tcl,v 1.284.2.240 2023/08/03 10:31:32 gustafn Exp $

Procedures in this file

Detailed information

Class ::xowiki::formfield::FormField (public)

 ::xotcl::Class ::xowiki::formfield::FormField[i] \
    [ -language_specific language_specific ]

Base FormField class. FormFields are objects, which can be outputted as well in ad_forms or asHTML included in wiki pages. FormFields support: - validation - help_text - error messages - internationalized pretty_values and inherit properties of the original datatypes via slots (e.g. for boolean entries). FormFields can be subclassed to ensure tailor-ability and high reuse. todo: at some later time, this could go into xotcl-core.

Switches:
-language_specific
(optional)
this parameter decides that the value collected by this formfield should be transparently stored as a message key. The translation language is that of the current package, determined by 'use_connection_locale' package parameter, connection locale and system settings.

Partial Call Graph (max 5 caller/called nodes):
%3 _ _ (public) ad_try ad_try (public) html::button html::button html::div html::div html::h5 html::h5 Class ::xowiki::formfield::FormField Class ::xowiki::formfield::FormField Class ::xowiki::formfield::FormField->_ Class ::xowiki::formfield::FormField->ad_try Class ::xowiki::formfield::FormField->html::button Class ::xowiki::formfield::FormField->html::div Class ::xowiki::formfield::FormField->html::h5

Testcases:
No testcase defined.

Class ::xowiki::formfield::ShuffleField (public)

 ::xotcl::Class ::xowiki::formfield::ShuffleField[i] \
    [ -shuffle_kind shuffle_kind ]

An abstract class for shuffling options and answers. The options can be used a content of checkboxes, radioboxes and the like. This is particular useful when creating quizzes.

Switches:
-shuffle_kind
(optional)
none|peruser|always

Partial Call Graph (max 5 caller/called nodes):
%3 nsf::object::alloc nsf::object::alloc nsf::relation::set nsf::relation::set nx::slotObj nx::slotObj xowiki::randomized_indices xowiki::randomized_indices (public) Class ::xowiki::formfield::ShuffleField Class ::xowiki::formfield::ShuffleField Class ::xowiki::formfield::ShuffleField->nsf::object::alloc Class ::xowiki::formfield::ShuffleField->nsf::relation::set Class ::xowiki::formfield::ShuffleField->nx::slotObj Class ::xowiki::formfield::ShuffleField->xowiki::randomized_indices

Testcases:
No testcase defined.

Class ::xowiki::formfield::candidate_box_select (public)

 ::xotcl::Class ::xowiki::formfield::candidate_box_select[i] \
    [ -as_box as_box ] [ -keep_order keep_order ] [ -dnd dnd ]

XOTcl class for selecting a subset from a list of candidates.

Switches:
-as_box
(optional)
makes something like in info box in wikipedia (right floated)
-keep_order
(optional)
when set, the user provided order is preserved, otherwise the order form the candidates is used.
-dnd
(optional)
allow drag and drop

Partial Call Graph (max 5 caller/called nodes):
%3 html::div html::div html::h3 html::h3 html::li html::li html::t html::t html::textarea html::textarea Class ::xowiki::formfield::candidate_box_select Class ::xowiki::formfield::candidate_box_select Class ::xowiki::formfield::candidate_box_select->html::div Class ::xowiki::formfield::candidate_box_select->html::h3 Class ::xowiki::formfield::candidate_box_select->html::li Class ::xowiki::formfield::candidate_box_select->html::t Class ::xowiki::formfield::candidate_box_select->html::textarea

Testcases:
No testcase defined.

Class ::xowiki::formfield::localized_richtext (public)

 ::xotcl::Class ::xowiki::formfield::localized_richtext[i]

This class can be used to provide an interface for specifying internationalized text strings saved in message keys via input from a form. Very similar to localized_text

See Also:
  • xowiki::formfield::localized_text

Partial Call Graph (max 5 caller/called nodes):
%3 nsf::object::alloc nsf::object::alloc nsf::relation::set nsf::relation::set Class ::xowiki::formfield::localized_richtext Class ::xowiki::formfield::localized_richtext Class ::xowiki::formfield::localized_richtext->nsf::object::alloc Class ::xowiki::formfield::localized_richtext->nsf::relation::set

Testcases:
No testcase defined.

Class ::xowiki::formfield::localized_text (public)

 ::xotcl::Class ::xowiki::formfield::localized_text[i]

This class can be used to provide an interface for specifying internationalized text strings saved in message keys via input from a form. When editing the content provided via the input field is saved together with an item-specific message keys in the message key tables via lang::util::convert_to_i18n. This formfield class is especially useful for xowiki items which have no language-prefix (e.g. folders or links). In other cases it is probably still a better idea to create same named pages with different language prefixes.

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 html::option html::option html::select html::select html::t html::t lang::util::convert_to_i18n lang::util::convert_to_i18n (public) lang::util::localize lang::util::localize (public) Class ::xowiki::formfield::localized_text Class ::xowiki::formfield::localized_text Class ::xowiki::formfield::localized_text->html::option Class ::xowiki::formfield::localized_text->html::select Class ::xowiki::formfield::localized_text->html::t Class ::xowiki::formfield::localized_text->lang::util::convert_to_i18n Class ::xowiki::formfield::localized_text->lang::util::localize

Testcases:
No testcase defined.

Class ::xowiki::formfield::numeric (public)

 ::xotcl::Class ::xowiki::formfield::numeric[i] [ -format format ] \
    [ -connection_locale connection_locale ] [ -strict strict ] \
    [ -keep_string_rep keep_string_rep ]

Field with numeric content. Depending on the format, the accepted value can be either an integer or a floating point number. The widget performs localization based on the setting of :locale. In case 'keep_string_rep' is not true, the widget converts the value to an internal representation to be able to evaluate numeric expressions by this. When 'keep_string_rep' is true, the original string representation is kept, and only validation is performed.

Switches:
-format
(optional)
format for output and determining integer property
-connection_locale
(optional)
when set, use the connection locale as source for internationalized input
-strict
(optional)
when set, use just use the locale for input checking. Otherwise, always accept as fallback what is accepted by en_US.
-keep_string_rep
(optional)
when true, do not convert from and to the internal representation, but preserve the original string.

Partial Call Graph (max 5 caller/called nodes):
%3 ad_conn ad_conn (public) ad_try ad_try (public) lc_numeric lc_numeric (public) lc_parse_number lc_parse_number (public) nsf::object::alloc nsf::object::alloc Class ::xowiki::formfield::numeric Class ::xowiki::formfield::numeric Class ::xowiki::formfield::numeric->ad_conn Class ::xowiki::formfield::numeric->ad_try Class ::xowiki::formfield::numeric->lc_numeric Class ::xowiki::formfield::numeric->lc_parse_number Class ::xowiki::formfield::numeric->nsf::object::alloc

Testcases:
No testcase defined.

Class ::xowiki::formfield::range (public)

 ::xotcl::Class ::xowiki::formfield::range[i] [ -min min ] [ -max max ] \
    [ -step step ] [ -with_output with_output ] \
    [ -output_prefix output_prefix ] [ -output_suffix output_suffix ]

HTML5 range input field. The range input is rendered as a slider by the actual browsers.

Switches:
-min
(optional)
minimum value of the value range
-max
(optional)
maximum value of the value range
-step
(optional)
increment steps when moving the slider
-with_output
(optional)
add an output box with show the actual slider value (requires JavaScript)
-output_prefix
(optional)
prepend string value to the actual slider value in the output display
-output_suffix
(optional)
append string value to the actual slider value in the output display

Partial Call Graph (max 5 caller/called nodes):
%3 html::input html::input html::output html::output html::t html::t nsf::object::alloc nsf::object::alloc nsf::relation::set nsf::relation::set Class ::xowiki::formfield::range Class ::xowiki::formfield::range Class ::xowiki::formfield::range->html::input Class ::xowiki::formfield::range->html::output Class ::xowiki::formfield::range->html::t Class ::xowiki::formfield::range->nsf::object::alloc Class ::xowiki::formfield::range->nsf::relation::set

Testcases:
No testcase defined.

Class ::xowiki::formfield::text_fields (public)

 ::xotcl::Class ::xowiki::formfield::text_fields[i]

Provide multiple text and short text entries. This field is a compound field which create for every text field a sub component. When the components are rendered, the items can be shuffled.

Partial Call Graph (max 5 caller/called nodes):
%3 html::div html::div html::li html::li html::t html::t html::ul html::ul nsf::object::alloc nsf::object::alloc Class ::xowiki::formfield::text_fields Class ::xowiki::formfield::text_fields Class ::xowiki::formfield::text_fields->html::div Class ::xowiki::formfield::text_fields->html::li Class ::xowiki::formfield::text_fields->html::t Class ::xowiki::formfield::text_fields->html::ul Class ::xowiki::formfield::text_fields->nsf::object::alloc

Testcases:
No testcase defined.

xowiki::formfield::CompoundField instproc get_named_sub_component_value (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 - space separated path of elements names in a potentially nested component structure (similar to dict)

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_test_items create_test_items (test xowf) xowiki::formfield::CompoundField instproc get_named_sub_component_value xowiki::formfield::CompoundField instproc get_named_sub_component_value test_create_test_items->xowiki::formfield::CompoundField instproc get_named_sub_component_value

Testcases:
create_test_items

xowiki::formfield::child_components (public)

 xowiki::formfield::child_components [ -filter filter ] objs

For every form-field obj in the provided objs, return a list of all child components (potentially leaf components of compound fields). The result list is filtered by the optional filter expression, which can refer to the current object via variable $_.

Switches:
-filter
(defaults to "true") (optional)
Parameters:
objs - input form-field objs

Partial Call Graph (max 5 caller/called nodes):
%3 Class ::xowf::test_item::Answer_manager Class ::xowf::test_item::Answer_manager (public) xowiki::formfield::child_components xowiki::formfield::child_components Class ::xowf::test_item::Answer_manager->xowiki::formfield::child_components xowf::test_item::Answer_manager instproc get_non_empty_file_formfields xowf::test_item::Answer_manager instproc get_non_empty_file_formfields (protected) xowf::test_item::Answer_manager instproc get_non_empty_file_formfields->xowiki::formfield::child_components

Testcases:
No testcase defined.

xowiki::formfield::dict_to_fc (public)

 xowiki::formfield::dict_to_fc [ -name name ] [ -type type ] dict

Convert the provided dict into form_constraint syntax (comma separated). The other direction would be more complex, since the fcs are interpreted from left to right, overwriting potentially previous values. The fc-interpretation creates already the form fields, produces intended errors, when certain attributes are not allowed, etc.

Switches:
-name
(optional)
optional form-field name
-type
(optional)
type of the form-field; if not specified, take it from key "_type" of the dict
Parameters:
dict - dict to be converted.

Partial Call Graph (max 5 caller/called nodes):
%3 test_dict_to_xx dict_to_xx (test xowiki) xowiki::formfield::dict_to_fc xowiki::formfield::dict_to_fc test_dict_to_xx->xowiki::formfield::dict_to_fc xowiki::formfield::dict_to_spec xowiki::formfield::dict_to_spec (public) xowiki::formfield::dict_to_spec->xowiki::formfield::dict_to_fc

Testcases:
dict_to_xx

xowiki::formfield::dict_to_spec (public)

 xowiki::formfield::dict_to_spec [ -aspair ] [ -name name ] dict

Convert the provided dict into a form-field spec together with the form-field name. When "-aspair" is specified the spec is returned in the list format as used by "create_components". If "-name" is not specified, the name has to be provided via dict member "_name", otherwise an exception is triggered.

Switches:
-aspair
(boolean) (defaults to "false") (optional)
-name
(optional)
Parameters:
dict

Partial Call Graph (max 5 caller/called nodes):
%3 test_dict_to_xx dict_to_xx (test xowiki) xowiki::formfield::dict_to_spec xowiki::formfield::dict_to_spec test_dict_to_xx->xowiki::formfield::dict_to_spec xowiki::formfield::dict_to_fc xowiki::formfield::dict_to_fc (public) xowiki::formfield::dict_to_spec->xowiki::formfield::dict_to_fc

Testcases:
dict_to_xx

xowiki::formfield::dict_value (public)

 xowiki::formfield::dict_value dict key [ default ]

Return the dict value of the specified "key" when this member exists. Otherwise return the default.

Parameters:
dict
key
default (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_dict_to_xx dict_to_xx (test xowiki) xowiki::formfield::dict_value xowiki::formfield::dict_value test_dict_to_xx->xowiki::formfield::dict_value

Testcases:
dict_to_xx

xowiki::formfield::enumeration instproc scores (public)

 <instance of xowiki::formfield::enumeration[i]> scores [ -r r ] \
    [ -f f ] [ -rk rk ] [ -fk fk ] [ -R R ] [ -W W ]
Switches:
-r
(defaults to "0") (optional)
number of answers which are true
-f
(defaults to "0") (optional)
number of answers which are false
-rk
(defaults to "0") (optional)
number checkmarks to a true answer
-fk
(defaults to "0") (optional)
number checkmarks to a false answer
-R
(optional)
number correct answered
-W
(optional)
number incorrect answered

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_test_items create_test_items (test xowf) xowiki::formfield::enumeration instproc scores xowiki::formfield::enumeration instproc scores test_create_test_items->xowiki::formfield::enumeration instproc scores

Testcases:
create_test_items

xowiki::formfield::fc_to_dict (public)

 xowiki::formfield::fc_to_dict form_constraints

Convert from form_constraint syntax to a dict. This is just a partial implementation to be probably extended in the future. it expects that the type is the first element and ignores everything not in the syntax "*=*", or skips "@*" fields. Don't expect this to be fully reversible.

Parameters:
form_constraints

Partial Call Graph (max 5 caller/called nodes):
%3 test_dict_to_xx dict_to_xx (test xowiki) xowiki::formfield::fc_to_dict xowiki::formfield::fc_to_dict test_dict_to_xx->xowiki::formfield::fc_to_dict xowiki::formfield::spec_to_dict xowiki::formfield::spec_to_dict (private) xowiki::formfield::fc_to_dict->xowiki::formfield::spec_to_dict

Testcases:
dict_to_xx

xowiki::formfield::spec_to_dict (private)

 xowiki::formfield::spec_to_dict -name name spec

Convert a single spec to a Tcl dict structure

Switches:
-name
(required)
Parameters:
spec

Partial Call Graph (max 5 caller/called nodes):
%3 xowiki::formfield::fc_to_dict xowiki::formfield::fc_to_dict (public) xowiki::formfield::spec_to_dict xowiki::formfield::spec_to_dict xowiki::formfield::fc_to_dict->xowiki::formfield::spec_to_dict

Testcases:
No testcase defined.
[ show source ]