1HTML::SuperForm::Field(U3s)er Contributed Perl DocumentatHiToMnL::SuperForm::Field(3)
2
3
4
6 HTML::SuperForm::Field - HTML form field base class
7
9 package myForm::SuperDuper;
10
11 use base 'HTML::SuperForm::Field';
12
13 sub init {}
14 sub prepare {}
15
16 sub to_html {
17 my $self = shift;
18
19 my $tag = qq|For some reason this text makes|;
20 $tag.= qq|the field super duper|
21 $tag.= qq|<input type="text" name="| . $self->name . '"';
22 $tag.= qq| value="| . $self->value . '"';
23 $tag.= '/' if $self->well_formed;
24 $tag.= '>';
25
26 return $tag;
27 }
28
29 1;
30
32 This is the base class for all the HTML form field objects.
33
35 CONSTRUCTOR
36 new($form, %args), new($form, \%args), new(%args), new(\%args)
37 $form is the HTML::SuperForm object to associate the field with.
38 %args usually has the following (each is also a method to access
39 its value):
40
41 name()
42 The name of the field.
43
44 default()
45 The default value to use before data has been submitted or if
46 the form isn't sticky.
47
48 Other possible arguments include:
49
50 sticky()
51 Determines whether the field is sticky or not. Defaults to what
52 the form object's sticky flag is set to. If no form object is
53 specified it defaults to false.
54
55 fallback()
56 Determines whether the field's value "falls back" to the
57 default if the field is sticky but no data has been submitted
58 for the field. Defaults to what the form object's fallback flag
59 is set to. If no form object is specified it defaults to false.
60
61 well_formed()
62 Determines whether the HTML generated is well-formed or not. If
63 true, a slash is added to the end of non-container tags (i.e.
64 <input type="text name="my_text"/>). Attributes such as
65 multiple, readonly, disabled, selected, and checked are also
66 set equal to true values instead of being left alone (i.e.
67 <input type="checkbox" checked="checked"> rather than just
68 <input type="checkbox" checked>).
69
70 values_as_labels(), value_as_label()
71 Determines whether the value specifed by value or values is
72 used as a label if no label is specified. Default is true.
73
74 disabled()
75 Determines whether the field is disabled or not.
76
77 Arguments not used by all the fields also include:
78
79 multiple()
80 Determines whether a field can have multiple values selected.
81 Only Select uses this feature.
82
83 readonly()
84 Determines whether a field is readonly. Used by fields such as
85 Text and Textarea.
86
87 init($config)
88 This method is the very first thing called in
89 HTML::SuperForm::Field's constructor. Subclasses of
90 HTML::SuperForm::Field should override this method to manipulate
91 the parameters passed in before processing them. An example is in
92 HTML::SuperForm::Field::Checkbox.
93
94 prepare()
95 This method is the very last thing called in
96 HTML::SuperForm::Field's constructor. Subclasses of
97 HTML::SuperForm::Field should override this method to add extra
98 information to the object for later use. An example of its use is
99 in the documentation for HTML::SuperForm under the section
100 EXAMPLES.
101
102 to_html()
103 This method returns the string representation of your field. When
104 the object is used in string context this method is called to
105 generate the string. Subclasses of HTML::SuperForm::Field should
106 override this method display a default layout. All of the basic
107 fields that come with HTML::SuperForm have this method, so look at
108 them for examples. The Counter example in HTML::SuperForm's
109 documentation could also be helpful.
110
112 HTML::SuperForm::Field::Text,
113 HTML::SuperForm::Field::Textarea,
114 HTML::SuperForm::Field::Select,
115 HTML::SuperForm::Field::Checkbox,
116 HTML::SuperForm::Field::Radio,
117 HTML::SuperForm::Field::CheckboxGroup,
118 HTML::SuperForm::Field::RadioGroup
119
121 John Allwine <jallwine86@yahoo.com>
122
124 Hey! The above document had some coding errors, which are explained
125 below:
126
127 Around line 495:
128 '=item' outside of any '=over'
129
130 Around line 516:
131 You forgot a '=back' before '=head1'
132
133
134
135perl v5.30.1 2020-01-30 HTML::SuperForm::Field(3)