1AnyEvent::XMPP::Ext::DaUtsaeFrorCmo(n3t)ributed Perl DocAunmyeEnvteantti:o:nXMPP::Ext::DataForm(3)
2
3
4
6 AnyEvent::XMPP::Ext::DataForm - XEP-0004 DataForm
7
10 This module represents a Data Form as specified in XEP-0004.
11
13 new (%args)
14 append_field ($field)
15 This method appends a field to the form. $field must have the
16 structure as described in "FIELD STRUCTURE" below.
17
18 from_node ($node)
19 This method interprets the AnyEvent::XMPP::Node object in $node as
20 data form XML node and reads out the fields and all associated
21 information.
22
23 ($node must be the XML node of the <x xmlns='jabber:x:data'> tag).
24
25 make_answer_form ($request_form)
26 This method initializes this form with default answers and other
27 neccessary fields from $request_form, which must be of type
28 AnyEvent::XMPP::Ext::DataForm or compatible.
29
30 The result will be a form with a copy of all fields which are not
31 of type "fixed". The fields will also have the default value copied
32 over.
33
34 The form type will be set to "submit".
35
36 The idea is: this creates a template answer form from
37 $request_form.
38
39 To strip out the unneccessary fields later you don't need call the
40 "clear_empty_fields" method.
41
42 clear_empty_fields
43 This method removes all fields that have no values and options.
44
45 remove_field ($field_or_var)
46 This method removes a field either by it's unique name or by
47 reference. $field_or_var can either be the unique name or the
48 actual field hash reference you get from "get_field" or
49 "get_fields".
50
51 set_form_type ($type)
52 This method sets the type of the form, which must be one of:
53
54 form, submit, cancel, result
55
56 form_type
57 This method returns the type of the form, which is one of the
58 options described in "set_form_type" above or undef if no type was
59 yet set.
60
61 get_reported_fields
62 If this is a search result this method returns more than one
63 element here. The returned list consists of fields as described in
64 "FIELD STRUCTURE", only that they lack values and options.
65
66 See also the "get_items" method.
67
68 get_items
69 If this form is a search result this method returns the list of
70 items of that search.
71
72 An item is a array ref of fields (field structure is described in
73 "FIELD STRUCTURE"). This method returns a list of items.
74
75 get_fields
76 This method returns a list of fields. Each field has the structure
77 as described in "FIELD STRUCTURE".
78
79 get_field ($var)
80 Returns the field with the unique field name $var or undef if no
81 such field is in this form.
82
83 set_field_value ($var, $value)
84 This method sets the value of the field with the unique name $var.
85 If the field has supports multiple values all values will be
86 removed and only $value will be added, if $value is undefined the
87 field's value will be deleted.
88
89 add_field_value ($var, $value)
90 This method adds the $value to the field with the unique name $var.
91 If the field doesn't support multiple values this method has the
92 same effect as "set_field_value".
93
94 to_simxml
95 This method converts the form to a data strcuture that you can pass
96 as "node" argument to the "simxml" function which is documented in
97 AnyEvent::XMPP::Util.
98
99 Example call might be:
100
101 my $node = $form->to_simxml;
102 simxml ($w, defns => $node->{ns}, node => $node);
103
104 NOTE: The returned simxml node has the "dns" field set so that no
105 prefixes are generated for the namespace it is in.
106
107 as_debug_string
108 This method returns a string that represents the form. Only for
109 debugging purposes.
110
112 {
113 label => 'field label',
114 type => 'field type',
115 var => '(unique) field name'
116 required => true or false value,
117 values => [
118 'value text',
119 ...
120 ],
121 options => [
122 ['option label', 'option text'],
123 ...
124 ]
125 }
126
127 For the semantics of all fields please consult XEP 0004.
128
130 XEP 0004
131
133 Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>"
134
136 Copyright 2007, 2008 Robin Redeker, all rights reserved.
137
138 This program is free software; you can redistribute it and/or modify it
139 under the same terms as Perl itself.
140
141
142
143perl v5.38.0 2023-07-20 AnyEvent::XMPP::Ext::DataForm(3)