Annotate

util/dataforms.lua @ 1994:9cc9b096c8f5

modulemanager: Module loading rewritten to gracefully deal with errors in module initialization.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 18 Oct 2009 05:17:07 +0500
parent 1958:e2b0026143c4
child 2061:e34fdca432a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
1 -- Prosody IM
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
4 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
6 -- COPYING file in the source package for more information.
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
7 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 957
diff changeset
8
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
9 local setmetatable = setmetatable;
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
10 local pairs, ipairs = pairs, ipairs;
954
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
11 local tostring, type = tostring, type;
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
12 local t_concat = table.concat;
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
13 local st = require "util.stanza";
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 module "dataforms"
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 local xmlns_forms = 'jabber:x:data';
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 local form_t = {};
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 local form_mt = { __index = form_t };
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 function new(layout)
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 return setmetatable(layout, form_mt);
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 function form_t.form(layout, data)
956
4c3f3d60a2f4 util.dataforms: Set form type when generating a form
Matthew Wild <mwild1@gmail.com>
parents: 955
diff changeset
27 local form = st.stanza("x", { xmlns = xmlns_forms, type = "form" });
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
28 if layout.title then
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
29 form:tag("title"):text(layout.title):up();
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
30 end
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
31 if layout.instructions then
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
32 form:tag("instructions"):text(layout.instructions):up();
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
33 end
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 for n, field in ipairs(layout) do
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
35 local field_type = field.type or "text-single";
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 -- Add field tag
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
37 form:tag("field", { type = field_type, var = field.name, label = field.label });
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38
1945
adfd7f3720f5 util.dataforms: Small fix to allow generating forms without specifying any input data
Matthew Wild <mwild1@gmail.com>
parents: 1944
diff changeset
39 local value = (data and data[field.name]) or field.value;
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 -- Add value, depending on type
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 if field_type == "hidden" then
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 if type(value) == "table" then
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 -- Assume an XML snippet
954
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
45 form:tag("value")
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
46 :add_child(value)
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
47 :up();
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 elseif value then
954
72e4639c9310 util.dataforms: Fixes for hidden field type
Matthew Wild <mwild1@gmail.com>
parents: 953
diff changeset
49 form:tag("value"):text(tostring(value)):up();
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 elseif field_type == "boolean" then
953
bed748f5dbb1 util.dataforms: Fix some field types which didn't render properly
Matthew Wild <mwild1@gmail.com>
parents: 952
diff changeset
52 form:tag("value"):text((value and "1") or "0"):up();
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 elseif field_type == "fixed" then
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 elseif field_type == "jid-multi" then
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 for _, jid in ipairs(value) do
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 form:tag("value"):text(jid):up();
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 elseif field_type == "jid-single" then
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 form:tag("value"):text(value):up();
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
61 elseif field_type == "text-single" or field_type == "text-private" then
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
62 form:tag("value"):text(value):up();
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
63 elseif field_type == "text-multi" then
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
64 -- Split into multiple <value> tags, one for each line
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
65 for line in value:gmatch("([^\r\n]+)\r?\n*") do
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
66 form:tag("value"):text(line):up();
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
67 end
1958
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
68 elseif field_type == "list-single" then
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
69 for _, val in ipairs(value) do
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
70 if type(val) == "table" then
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
71 form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
72 else
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
73 form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
74 end
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
75 end
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77
952
ef648f49e734 util.dataforms: Add support for <required/> fields
Matthew Wild <mwild1@gmail.com>
parents: 951
diff changeset
78 if field.required then
ef648f49e734 util.dataforms: Add support for <required/> fields
Matthew Wild <mwild1@gmail.com>
parents: 951
diff changeset
79 form:tag("required"):up();
ef648f49e734 util.dataforms: Add support for <required/> fields
Matthew Wild <mwild1@gmail.com>
parents: 951
diff changeset
80 end
ef648f49e734 util.dataforms: Add support for <required/> fields
Matthew Wild <mwild1@gmail.com>
parents: 951
diff changeset
81
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 -- Jump back up to list of fields
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 form:up();
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 end
851
b48c7ed3f7f8 util.dataforms: Return the form
Matthew Wild <mwild1@gmail.com>
parents: 845
diff changeset
85 return form;
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
88 local field_readers = {};
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
89
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 function form_t.data(layout, stanza)
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
91 local data = {};
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
93 for field_tag in stanza:childtags() do
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
94 local field_type = field_tag.attr.type;
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
95
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
96 local reader = field_readers[field_type];
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
97 if reader then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
98 data[field_tag.attr.var] = reader(field_tag);
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
99 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
100
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
101 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
102 return data;
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 end
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
105 field_readers["text-single"] =
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
106 function (field_tag)
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
107 local value = field_tag:child_with_name("value");
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
108 if value then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
109 return value[1];
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
110 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
111 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
112
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
113 field_readers["text-private"] =
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
114 field_readers["text-single"];
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
115
1944
754eebd31538 util.dataforms: Support for jid-single field type especially for Florob :)
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
116 field_readers["jid-single"] =
754eebd31538 util.dataforms: Support for jid-single field type especially for Florob :)
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
117 field_readers["text-single"];
754eebd31538 util.dataforms: Support for jid-single field type especially for Florob :)
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
118
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
119 field_readers["text-multi"] =
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
120 function (field_tag)
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
121 local result = {};
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
122 for value_tag in field_tag:childtags() do
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
123 if value_tag.name == "value" then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
124 result[#result+1] = value_tag[1];
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
125 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
126 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
127 return t_concat(result, "\n");
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
128 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
129
1958
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
130 field_readers["list-single"] =
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
131 field_readers["text-single"];
e2b0026143c4 util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Matthew Wild <mwild1@gmail.com>
parents: 1945
diff changeset
132
955
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
133 field_readers["boolean"] =
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
134 function (field_tag)
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
135 local value = field_tag:child_with_name("value");
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
136 if value then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
137 if value[1] == "1" or value[1] == "true" then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
138 return true;
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
139 else
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
140 return false;
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
141 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
142 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
143 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
144
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
145 field_readers["hidden"] =
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
146 function (field_tag)
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
147 local value = field_tag:child_with_name("value");
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
148 if value then
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
149 return value[1];
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
150 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
151 end
98ca5a753fee util.dataforms: Support for retriving the field value data from forms
Matthew Wild <mwild1@gmail.com>
parents: 954
diff changeset
152
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
153 return _M;
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
156 --[=[
845
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 Layout:
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 {
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 title = "MUC Configuration",
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 instructions = [[Use this form to configure options for this MUC room.]],
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 { name = "FORM_TYPE", type = "hidden", required = true };
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 { name = "field-name", type = "field-type", required = false };
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 }
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167
fc3dced9801e util.dataforms: First commit, incomplete
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168
951
4b9207949735 util.dataforms: Fixed to actually work, mostly
Matthew Wild <mwild1@gmail.com>
parents: 851
diff changeset
169 --]=]