| |
181 |
181 |
[::xowiki::formfield::dict_to_spec $dict] |
| |
182 |
182 |
|
| |
183 |
183 |
aa_equals "fc_to_dict (show results of reverse operation)" \ |
| |
184 |
184 |
[::xowiki::formfield::fc_to_dict $fc] \ |
| |
185 |
185 |
{myname {_name myname _type text label {Hello, world!} enabled 1 _definition {text,label=Hello__COMMA__ world!,enabled=1}}} |
| |
186 |
186 |
|
| |
187 |
187 |
# |
| |
188 |
188 |
# dict_value |
| |
189 |
189 |
# |
| |
190 |
190 |
aa_equals "dict_value exists" \ |
| |
191 |
191 |
[::xowiki::formfield::dict_value $dict label] \ |
| |
192 |
192 |
{Hello, world!} |
| |
193 |
193 |
aa_equals "dict_value not exists, no default" \ |
| |
194 |
194 |
[::xowiki::formfield::dict_value $dict title] \ |
| |
195 |
195 |
{} |
| |
196 |
196 |
aa_equals "dict_value not exists, default" \ |
| |
197 |
197 |
[::xowiki::formfield::dict_value $dict title xxx] \ |
| |
198 |
198 |
{xxx} |
| |
199 |
199 |
} |
| |
200 |
200 |
|
| |
|
201 |
aa_register_case \ |
| |
|
202 |
-cats {api smoke production_safe} \ |
| |
|
203 |
-procs { |
| |
|
204 |
"::xowiki::Page instproc create_form_fields_from_form_constraints" |
| |
|
205 |
} \ |
| |
|
206 |
form_fields_from_form_constraints { |
| |
|
207 |
|
| |
|
208 |
Create (different) types of form-field with minimal interface. |
| |
|
209 |
|
| |
|
210 |
} { |
| |
|
211 |
::xo::require_html_procs |
| |
|
212 |
set p1 [xowiki::Page new \ |
| |
|
213 |
-name en:foo \ |
| |
|
214 |
-package_id [ad_conn package_id] \ |
| |
|
215 |
-destroy_on_cleanup] |
| |
|
216 |
aa_log "p1 = $p1" |
| |
|
217 |
foreach fc { |
| |
|
218 |
{t:textarea,value=foo} |
| |
|
219 |
{show_ip:boolean,horizontal=true,default=t,label=#xowf.Show_IP#} |
| |
|
220 |
{date:date,default=2022-02-01 22:03:00} |
| |
|
221 |
} props { |
| |
|
222 |
{name t rows 2 cols 80} |
| |
|
223 |
{name show_ip value t horizontal true required false label #xowf.Show_IP#} |
| |
|
224 |
{name date value "2022-02-01 22:03:00"} |
| |
|
225 |
} { |
| |
|
226 |
set ff [$p1 create_form_fields_from_form_constraints \ |
| |
|
227 |
[list $fc]] |
| |
|
228 |
|
| |
|
229 |
aa_log "<pre>[$ff serialize]</pre>" |
| |
|
230 |
#aa_log "[$ff name] [$ff info class] [$ff value]" |
| |
|
231 |
foreach {k v} $props { |
| |
|
232 |
aa_true "$k has value '$v' == '[$ff $k]'" {[$ff $k] eq $v} |
| |
|
233 |
} |
| |
|
234 |
dom createDocument html doc |
| |
|
235 |
set root [$doc documentElement] |
| |
|
236 |
$root appendFromScript { |
| |
|
237 |
$ff render_input |
| |
|
238 |
} |
| |
201 |
239 |
# |
| |
|
240 |
# Here we could check with xpath the content of the rended |
| |
|
241 |
# form field. |
| |
|
242 |
# |
| |
|
243 |
set HTML [lmap n [$root childNode] {$n asHTML}] |
| |
|
244 |
aa_log "<pre>[ns_quotehtml $HTML]</pre>" |
| |
|
245 |
} |
| |
|
246 |
} |
| |
|
247 |
|
| |
|
248 |
# |
| |
202 |
249 |
# Local variables: |
| |
203 |
250 |
# mode: tcl |
| |
204 |
251 |
# tcl-indent-level: 4 |
| |
205 |
252 |
# indent-tabs-mode: nil |
| |
206 |
253 |
# End: |