Reactor/HTML/Form.pm untested

filter: Statementstmt 0.0% 0 / 338 Branchbran 0.0% 0 / 96 Conditioncond 0.0% 0 / 133 Subroutinesub 0.0% 0 / 25 Podpod 0.0% 0 / 19 totaltotal 0.0% 0 / 611 CC 49 SCAR 45.4
CC
49
Cov
0%
input
272.0
select
132.0
textarea
72.0
CRAP 93.7
1 ##############################################################################
2 ##
3 ## Web::Reactor application machinery
4 ## 2013-2017 (c) Vladi Belperchinov-Shabanski "Cade"
5 ## <cade@bis.bg> <cade@biscom.net> <cade@cpan.org>
6 ##
7 ## LICENSE: GPLv2
8 ##
9 ##############################################################################
10 package Web::Reactor::HTML::Form;
11 use strict;
12 use Exporter;
13 use Data::Tools;
14 use Exception::Sink;
15  
16 use Web::Reactor::HTML::Utils;
17  
18 # FIXME: TODO: use common func to add html elements common tags: ID,DISABLED,etc.
19 # FIXME: TODO: ...including abstract ones as GEO(metry)
20 # FIXME: TODO: change VALUE to be html value (currently it is DATA), and DISPLAY to be visible text (currently it is VALUE)
21  
22 use parent 'Web::Reactor::Base';
23  
24 ##############################################################################
25  
26 sub new
27 {
28 my $class = shift;
29 my %env = @_;
30  
31 $class = ref( $class ) || $class;
32 my $self = {
33 'ENV' => \%env,
34 };
35  
36 bless $self, $class;
37  
38 # FIXME: move as argument, not env option
39 $self->__set_reo( $env{ 'REO_REACTOR' } );
40  
41 return $self;
42 }
43  
44 ##############################################################################
45  
46 sub html_new_id
47 {
48 my $self = shift;
49  
50 my $form_name = $self->{ 'FORM_NAME' };
51 $form_name or boom "empty form name, need begin() first";
52  
53 my $reo = $self->get_reo();
54 my $psid = $reo->get_page_session_id();
55 $self->{ 'HTML_ID_COUNTER' }++;
56 # FIXME: hash $psid once more to hide...
57 return $form_name . "_EID_$psid\_" . $self->{ 'HTML_ID_COUNTER' } . '_' . int(rand()*10_000_000_000);
58 }
59  
60 sub __check_name
61 {
62 my $name = shift;
63 $name =~ /^[A-Z_0-9:.]+$/ or boom "invalid or empty NAME attribute [$name]";
64 return 1;
65 }
66  
67 ##############################################################################
68  
69 sub begin
70 {
71 my $self = shift;
72  
73 my %opt = @_;
74  
75 my $form_name = uc $opt{ 'NAME' };
76 my $form_id = $opt{ 'ID' };
77 my $method = uc $opt{ 'METHOD' } || 'POST';
78 my $action = $opt{ 'ACTION' } || '?';
79 my $default_button = $opt{ 'DEFAULT_BUTTON' };
80 my $state_keeper = $opt{ 'STATE_KEEPER' };
81 my $extra_args = $opt{ 'EXTRA_ARGS' } || {};
82  
83 $self->{ 'CLASS_MAP' } = $opt{ 'CLASS_MAP' } || {};
84  
85 __check_name( $form_name );
86 $method =~ /^(POST|GET)$/ or boom "METHOD can either POST or GET";
87  
88 my $reo = $self->get_reo();
89 my $psid = $reo->get_page_session_id();
90  
91 $form_id ||= $form_name;
92 $form_id .= "_$psid";
93  
94 $self->{ 'FORM_NAME' } = $form_name;
95 $self->{ 'FORM_ID' } = $form_id = $form_id || $self->html_new_id();
96 $self->{ 'RADIO' } = {};
97 $self->{ 'RET_MAP' } = {}; # return data mapping (combo, checkbox, etc.)
98
99 my $options;
100
101 $options .= " autocomplete='off'" if $opt{ 'NO_AUTOCOMPLETE' };
102  
103 my $text;
104  
105 # FIXME: TODO: debug info inside html text, begin formname end etc.
106  
107 my $reo = $self->get_reo();
108  
109 my $page_session = $reo->get_page_session();
110 $page_session->{ ':FORM_DEF' }{ $form_name } = {};
111  
112 $state_keeper ||= $reo->args_here( FORM_NAME => $form_name, %$extra_args ); # keep state and more args
113 $text .= "<form name='$form_name' id='$form_id' action='$action' method='$method' enctype='multipart/form-data' $options>";
114 $text .= "</form>";
115 $text .= "<input type=hidden name='_' value='$state_keeper' form='$form_id'>";
116 $text .= "<input style='display: none;' name='__avoidiebug__' form='$form_id'>"; # stupid IE bugs
117 if( $default_button )
118 {
119 $text .= "<input style='display: none;' type='image' name='BUTTON:$default_button' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQI12NgYGBgAAAABQABXvMqOgAAAABJRU5ErkJggg==' border=0 height=0 width=0 onDblClick='return false;' form='$form_id'>"
120 }
121 return $text;
122 }
123  
124 sub end
125 {
126 my $self = shift;
127  
128 my $text;
129  
130 $text .= $self->end_radios();
131 # $text .= "</form>";
132  
133 # FIXME: TODO: debug info inside html text, begin formname end etc.
134  
135 my $reo = $self->get_reo();
136 my $page_session = $reo->get_page_session();
137  
138 my $form_name = $self->{ 'FORM_NAME' };
139 $page_session->{ ':FORM_DEF' }{ $form_name }{ 'RET_MAP' } = $self->{ 'RET_MAP' };
140  
141 $text .= "\n";
142 return $text;
143 }
144  
145 sub __ret_map_set
146 {
147 my $self = shift;
148 my $name = shift; # entry input name
149  
150 $self->{ 'RET_MAP' }{ $name } ||= {};
151  
152 if( @_ > 0 )
153 {
154 boom "expected even number of arguments" unless @_ % 2 == 0;
155 %{ $self->{ 'RET_MAP' }{ $name } } = ( %{ $self->{ 'RET_MAP' }{ $name } }, @_ );
156 }
157  
158 return $self->{ 'RET_MAP' }{ $name };
159 }
160  
161 ##############################################################################
162 # classic html input checkbox
163  
164 sub checkbox
165 {
166 my $self = shift;
167  
168 my %opt = @_;
169  
170 my $name = uc $opt{ 'NAME' };
171 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'CHECKBOX' } || 'checkbox';
172 my $value = $opt{ 'VALUE' } ? 1 : 0;
173 my $args = $opt{ 'ARGS' };
174  
175 __check_name( $name );
176  
177 my $options;
178 $options .= $value ? " checked " : undef;
179  
180 my $text;
181  
182 my $ch_id = $self->html_new_id(); # checkbox data holder
183  
184 my $form_id = $self->{ 'FORM_ID' };
185 #print STDERR "ccccccccccccccccccccc CHECKBOX [$name] [$value]\n";
186 #$text .= "<input type='checkbox' name='$name' value='1' $options>";
187 $text .= "\n";
188 $text .= "<input type='hidden' name='$name' id='$ch_id' value='$value' form='$form_id' $args>";
189 # $text .= qq[ <input type='checkbox' $options checkbox_data_input_id="$ch_id" onclick='document.getElementById( "$ch_id" ).value = this.checked ? 1 : 0'> ];
190 $text .= qq[ <input type='checkbox' $options data-checkbox-input-id="$ch_id" form='$form_id' onclick='reactor_form_checkbox_toggle(this)' class='$class'> ];
191 $text .= "\n";
192  
193 return $text;
194 }
195  
196 ##############################################################################
197 # multi-stages css-styled checkbox
198  
199 sub checkbox_multi
200 {
201 my $self = shift;
202  
203 my %opt = @_;
204  
205 my $name = uc $opt{ 'NAME' };
206 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'CHECKBOX' } || 'checkbox';
207 my $value = $opt{ 'VALUE' };
208 my $args = $opt{ 'ARGS' };
209 my $stages = $opt{ 'STAGES' } || 2;
210 my $labels = $opt{ 'LABELS' } || [ 'x', '&radic;' ];
211 my $hint = $opt{ 'HINT' };
212  
213 __check_name( $name );
214  
215 $value = abs( int( $value ) );
216 $value = 0 if $value >= $stages;
217  
218 my $options;
219 my $current_class;
220  
221 for my $s ( 0 .. $stages - 1 )
222 {
223 my $c = ref( $class ) eq 'ARRAY' ? $class->[ $s ] : "$class-$s cursor-pointer";
224 my $v = $labels->[ $s ];
225 $options .= "data-value-label-$s='$v' ";
226 $options .= "data-value-class-$s='$c' ";
227 $current_class = $c if $s == 0;
228 $current_class = $c if $s == $value;
229 }
230 my $label = $labels->[ $value ];
231  
232 my $text;
233  
234 my $reo = $self->get_reo();
235 my $hint_handler = $hint ? html_hover_layer( $reo, VALUE => $hint ) : undef;
236  
237 my $cb_id = $self->html_new_id(); # checkbox id
238 my $el_id = $self->html_new_id(); # checkbox label element id
239  
240 my $form_id = $self->{ 'FORM_ID' };
241 #print STDERR "ccccccccccccccccccccc CHECKBOX [$name] [$value]\n";
242 #$text .= "<input type='checkbox' name='$name' value='1' $options>";
243 $text .= "\n";
244 $text .= "<input type='hidden' name='$name' id='$cb_id' value='$value' form='$form_id' $args>";
245 $text .= qq[ <span class='$current_class' id='$el_id' data-stages='$stages' data-checkbox-input-id="$cb_id" onclick='reactor_form_multi_checkbox_toggle(this)' $hint_handler $options>$label</span> ];
246 $text .= "<script>reactor_form_multi_checkbox_setup_id( '$el_id' )</script>";
247 $text .= "\n";
248  
249 return $text;
250 }
251  
252 ##############################################################################
253  
254 sub checkbox_3state
255 {
256 my $self = shift;
257  
258 my %args = @_; # to fix uneven args
259 return $self->checkbox_multi( %args, STAGES => 3, LABELS => [ '?', '&radic;', 'x' ] );
260 }
261  
262 ##############################################################################
263  
264 sub radio
265 {
266 my $self = shift;
267  
268 my %opt = @_;
269  
270 my $name = uc $opt{ 'NAME' };
271 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'RADIO' } || 'radio';
272 my $on = $opt{ 'ON' }; # active?
273 my $ret = $opt{ 'RET' } || $opt{ 'RETURN' } || 1; # map return value!
274  
275 __check_name( $name );
276  
277 my $text;
278  
279 my $val = $self->html_new_id();
280  
281 my $form_id = $self->{ 'FORM_ID' };
282 my $checked = $on ? 'checked' : undef;
283 $text .= "<input type='radio' $checked name='$name' value='$val' form='$form_id'>";
284  
285 $self->__ret_map_set( $name, $val => $ret ) if defined $ret;
286  
287 $text .= "\n";
288 return $text;
289 }
290  
291 sub end_radios
292 {
293 my $self = shift;
294  
295 my $text;
296  
297 # nothing for now
298  
299 return $text;
300 }
301  
302 ##############################################################################
303 =pod
304  
305 $form->select( DATA => $data );
306  
307 $data = [
308 {
309 KEY => string
310 VALUE => string
311 ORDER => \d+
312 },
313 ];
314  
315 $data = {
316 KEY => {
317 KEY => string
318 VALUE => string
319 ORDER => \d+
320 },
321 KEY => value...,
322 };
323  
324 =cut
325  
326 sub select
327 {
328 my $self = shift;
329  
330 my %opt = @_;
331  
332 my $name = uc $opt{ 'NAME' };
333 my $id = $opt{ 'ID' };
334 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'SELECT' } || 'select';
335 my $rows = $opt{ 'SIZE' } || $opt{ 'ROWS' } || 1;
336 my $args = $opt{ 'ARGS' };
337  
338 __check_name( $name );
339  
340 my $data = $opt{ 'DATA' }; # array reference or hash reference, inside hashesh are the same
341 my $sel_hr = $opt{ 'SELECTED' }; # hashref with selected keys (values are true's)
342 my $sel_data;
343  
344 if( ref($data) eq 'HASH' )
345 {
346 $sel_data = [];
347 my %res;
348 while( my ( $k, $v ) = each %$data )
349 {
350 my %e = ( 'KEY' => $k );
351 if( ref($v) eq 'HASH' )
352 {
353 %e = ( %e, %$v );
354 }
355 else
356 {
357 $e{ 'VALUE' } = $v;
358 }
359 push @$sel_data, \%e;
360 }
361 # FIXME: @$sel_data = sort { ... } @$sel_data;
362 }
363 elsif( ref($data) eq 'ARRAY' )
364 {
365 $sel_data = $data;
366 }
367 else
368 {
369 boom "DATA must be either ARRAY or HASH reference";
370 }
371 hash_uc_ipl( $_ ) for @$sel_data;
372  
373 my $extra = $opt{ 'EXTRA' };
374  
375 my $text;
376 my $form_id = $self->{ 'FORM_ID' };
377  
378 if( $opt{ 'RADIO' } )
379 {
380 for my $hr ( @$sel_data )
381 {
382 my $sel = $hr->{ 'SELECTED' } ? 'selected' : ''; # is selected?
383 my $key = $hr->{ 'KEY' };
384 my $value = $hr->{ 'VALUE' };
385  
386 $sel = 'selected' if $sel_hr and $sel_hr->{ $key };
387 #print STDERR "sssssssssssssssssssssssss RADIO [$name] [$value] [$key] $sel\n";
388 $text .= $self->radio( NAME => $name, RET => $key, ON => $sel, EXTRA => $extra ) . " $value";
389 $text .= "<br>" if $opt{ 'RADIO' } != 2;
390 }
391 # FIXME: kakvo stava ako nqma dadeno selected pri submit na formata?
392 }
393 else
394 {
395 my $multiple = 'multiple' if $opt{ 'MULTIPLE' };
396 $text .= "<select class='$class' id='$id' name='$name' size='$rows' $multiple form='$form_id' $args $extra>";
397  
398 my $pad = '&nbsp;' x 3;
399 for my $hr ( @$sel_data )
400 {
401 my $sel = $hr->{ 'SELECTED' } ? 'selected' : ''; # is selected?
402 my $key = $hr->{ 'KEY' };
403 my $value = $hr->{ 'VALUE' };
404 my $id = $self->html_new_id();
405 $self->__ret_map_set( $name, $id => $key );
406  
407 $sel = 'selected' if $sel_hr and $sel_hr->{ $key };
408 #print STDERR "sssssssssssssssssssssssss COMBO [$name] [$value] [$key] $sel\n";
409 $text .= "<option value='$id' $sel>$value$pad</option>\n";
410 }
411  
412 $text .= "</select>";
413 }
414 # print STDERR "FOOOOOOOOOOOOOOOOOOOOOORM[$text](@$sel){@$order}";
415  
416 $text .= "\n";
417 return $text;
418 }
419  
420 sub combo
421 {
422 my $self = shift;
423  
424 my %opt = @_;
425 $opt{ 'ROWS' } ||= 1;
426 return $self->select( %opt );
427 }
428  
429 ##############################################################################
430  
431 sub textarea
432 {
433 my $self = shift;
434  
435 my %opt = @_;
436  
437 my $name = uc $opt{ 'NAME' };
438 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'TEXTAREA' } || 'textarea';
439 my $id = $opt{ 'ID' };
440 my $data = $opt{ 'VALUE' };
441 my $rows = $opt{ 'ROWS' } || 10;
442 my $cols = $opt{ 'COLS' } || 5;
443 my $maxl = $opt{ 'MAXLEN' } || $opt{ 'MAX' };
444 my $geo = $opt{ 'GEOMETRY' } || $opt{ 'GEO' };
445 my $args = $opt{ 'ARGS' };
446  
447 __check_name( $name );
448  
449 ( $cols, $rows ) = ( $1, $2 ) if $geo =~ /(\d+)[\*\/\\](\d+)/i;
450  
451  
452 my $options;
453  
454 $options .= "disabled='disabled' " if $opt{ 'DISABLED' };
455 $options .= "maxlength='$maxl' " if $maxl > 0;
456 $options .= "id='$id' " if $id ne '';
457 $options .= "readonly='readonly' " if $opt{ 'READONLY' } || $opt{ 'RO' };
458 $options .= "required='required' " if $opt{ 'REQUIRED' } || $opt{ 'REQ' };
459 $options .= "onFocus=\"this.value=''\" " if $opt{ 'FOCUS_AUTO_CLEAR' };
460  
461 my $extra = $opt{ 'EXTRA' };
462 $options .= " $extra ";
463  
464 $data = str_html_escape( $data );
465  
466 my $text;
467 my $form_id = $self->{ 'FORM_ID' };
468  
469 $text .= "<textarea class='$class' name='$name' rows='$rows' cols='$cols' $options form='$form_id' $args>$data</textarea>";
470  
471 $text .= "\n";
472 return $text;
473 }
474  
475 ##############################################################################
476  
477 sub input
478 {
479 my $self = shift;
480  
481 my %opt = @_;
482  
483 my $name = uc $opt{ 'NAME' };
484 my $class = $opt{ 'CLASS' } || $self->{ 'CLASS_MAP' }{ 'INPUT' } || 'line';
485 my $value = $opt{ 'VALUE' };
486 my $id = $opt{ 'ID' };
487 # FIXME: default data?
488 my $size = $opt{ 'SIZE' } || $opt{ 'LEN' } || $opt{ 'WIDTH' };
489 my $maxl = $opt{ 'MAXLEN' } || $opt{ 'MAX' };
490  
491 my $len = $opt{ 'LEN' };
492 my $args = $opt{ 'ARGS' };
493 my $hid = $opt{ 'HIDDEN' };
494 my $ret = $opt{ 'RET' } || $opt{ 'RETURN' }; # if return value should be mapped, works only with HIDDEN
495  
496 my $clear = $opt{ 'CLEAR' };
497  
498 $size = $maxl = $len if $len > 0;
499  
500 my $options;
501  
502 $options .= "disabled='disabled' " if $opt{ 'DISABLED' };
503 $options .= "size='$size' " if $size > 0;
504 $options .= "maxlength='$maxl' " if $maxl > 0;
505 $options .= "id='$id' " if $id ne '';
506 $options .= "type='password' " if $opt{ 'PASS' } || $opt{ 'PASSWORD' };
507 $options .= "type='hidden' " if $hid; # FIXME: handle TYPE better
508 $options .= "readonly='readonly' " if $opt{ 'READONLY' } || $opt{ 'RO' };
509 $options .= "required='required' " if $opt{ 'REQUIRED' } || $opt{ 'REQ' };
510 $options .= "onFocus=\"this.value=''\" " if $opt{ 'FOCUS_AUTO_CLEAR' };
511 $options .= "autocomplete='off' " if $opt{ 'NO_AUTOCOMPLETE' };
512  
513  
514 my $extra = $opt{ 'EXTRA' };
515 $options .= " $extra ";
516  
517 $value = str_html_escape( $value );
518  
519 __check_name( $name );
520  
521 if( $hid and defined $ret )
522 {
523 # if input is hidden and return value mapping requested, VALUE is not used!
524 $value = $self->html_new_id();
525 $self->__ret_map_set( $name, $value => $ret );
526 }
527  
528 my $clear_tag;
529 if( $clear )
530 {
531 my $reo = $self->get_reo();
532 my $clear_hint_handler = html_hover_layer( $reo, VALUE => 'Clear field' );
533  
534 if( $clear =~ /^[a-z_\-0-9\/]+\.(png|jpg|jpeg|gif|svg)$/ )
535 {
536 $clear_tag = qq[ <img class='icon icon-clear' src='$clear' border='0' onClick='return set_value("$id", "")' $clear_hint_handler > ];
537 }
538 else
539 {
540 my $s = $clear eq 1 ? '&otimes;' : $clear;
541 $clear_tag = qq[ <span class='icon icon-clear' border='0' onClick='return set_value("$id", "")' $clear_hint_handler >$s</span> ];
542 }
543 }
544  
545 my $text;
546  
547 my $form_id = $self->{ 'FORM_ID' };
548 $text .= "<input class='$class' name='$name' value='$value' $options form='$form_id' $args>$clear_tag";
549  
550 $text .= "\n";
551 return $text;
552 }
553  
554 ##############################################################################
555  
556 # TODO: include button support
557 sub button
558 {
559 my $self = shift;
560  
561 my %opt = @_;
562  
563 my $name = uc $opt{ 'NAME' };
564 my $id = $opt{ 'ID' };
565 my $class = $opt{ 'CLASS' } || 'button';
566 my $value = $opt{ 'VALUE' };
567 my $args = $opt{ 'ARGS' };
568  
569 $value =~ s/'//g;
570 $value = str_html_escape( $value );
571  
572 __check_name( $name );
573  
574 my $options;
575
576 if( $opt{ 'DISABLED' } )
577 {
578 $options .= "disabled='disabled' " ;
579 $class .= " disabled-button";
580 }
581  
582 my $text;
583  
584 $name =~ s/^button://i;
585  
586 my $form_id = $self->{ 'FORM_ID' };
587 $text .= "<input class='$class' id='$id' type='submit' name='button:$name' value='$value' onDblClick='return false;' form='$form_id' $options $args>";
588  
589 $text .= "\n";
590 return $text;
591 }
592  
593 sub image_button
594 {
595 my $self = shift;
596  
597 my %opt = @_;
598  
599 my $name = uc $opt{ 'NAME' };
600 my $id = $opt{ 'ID' };
601 my $class = $opt{ 'CLASS' } || 'image_button';
602 my $src = $opt{ 'SRC' } || $opt{ 'IMG' };
603 my $args = $opt{ 'ARGS' };
604 my $extra = $opt{ 'EXTRA' };
605  
606 my $options;
607  
608 # FIXME: make this for all entries! common func?
609 for my $o ( qw( HEIGHT WIDTH ONMOUSEOVER ) )
610 {
611 my $e = $opt{ $o };
612 # FIXME: escape? $e
613 $options .= "$o='$e' " if $e ne '';
614 }
615  
616 __check_name( $name );
617  
618 my $text;
619  
620 my $form_id = $self->{ 'FORM_ID' };
621 $name =~ s/^button://i;
622 $text .= "<input class='$class' id='$id' type='image' name='button:$name' src='$src' border=0 $options onDblClick='return false;' $args form='$form_id' $extra>";
623  
624 $text .= "\n";
625 return $text;
626 }
627  
628 sub image_button_default
629 {
630 my $self = shift;
631  
632 my %opt = @_;
633  
634 my $user_agent = $self->get_reo()->get_user_session_agent();
635  
636 my $default_class = 'hidden';
637 $default_class = 'hidden2' if $user_agent =~ /MSIE|Safari/;
638  
639 $opt{ 'HEIGHT' } = 0;
640 $opt{ 'WIDTH' } = 0;
641 $opt{ 'CLASS' } = $opt{ 'CLASS' } || $default_class;
642  
643 return $self->image_button( %opt );
644 }
645  
646 sub get_id
647 {
648 my $self = shift;
649  
650 return $self->{ 'FORM_ID' };
651 }
652  
653 =pod
654  
655 my $form = new Review::HTML::Form;
656  
657 $text .= $form->image_submit_default( NAME => 'def_but', SRC => 'img/empty.png' );
658  
659 $text .= $form->line( NAME => 'line_one', DATA => ( $I{ 'LINE_ONE' } || 'ne se chete' ) );
660  
661 $text .= $form->begin( NAME => 'try1' );
662 $text .= 'cb1' . $form->cb( NAME => 'cb1', VAL => 1 );
663 $text .= 'cb2' . $form->cb( NAME => 'cb2', VAL => 0 );
664 $text .= 'cb3' . $form->cb( NAME => 'cb3', VAL => 0, MAX => 3, RET => [ 'qwe', 'asd', '[-]' ] );
665 $text .= "<p>";
666  
667 $text .= "<hr noshade>";
668 $text .= 'r1' . $form->radio( NAME => 'r1' );
669 $text .= 'r2' . $form->radio( NAME => 'r1' );
670 $text .= 'r3' . $form->radio( NAME => 'r1', ON => 1 );
671 $text .= 'r4' . $form->radio( NAME => 'r1' );
672 $text .= 'r5' . $form->radio( NAME => 'r1' );
673 $text .= "<hr noshade>";
674 $text .= 'r1' . $form->radio( NAME => 'r2', ON => 1 );
675 $text .= 'r2' . $form->radio( NAME => 'r2', RET => 'asd' );
676 $text .= 'r3' . $form->radio( NAME => 'r2', RET => 'qwe' );
677 $text .= 'r4' . $form->radio( NAME => 'r2', RET => 'zxc' );
678 $text .= 'r5' . $form->radio( NAME => 'r2', RET => '[-]' );
679 $text .= "<hr noshade>";
680  
681 my $data = {
682 'one' => 'This is test one',
683 'opa' => 'Opa test ooooooe',
684 'two' => 'Test two tralala',
685 'tra' => 'Tralala again+++',
686 };
687  
688 $text .= $form->select( NAME => 'sel2', DATA => $data, SELECTED => [ 'opa' ], ROWS => 4 );
689  
690 $text .= "<p>";
691 $text .= $form->button( NAME => 'bbb', VALUE => '"%!@#$&^' );
692 $text .= $form->end();
693  
694 =cut
695  
696 ##############################################################################
697 1;
698 ##############################################################################