Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / HTML::Form.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "HTML::Form 3"
132 .TH HTML::Form 3 "2009-07-07" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 HTML::Form \- Class that represents an HTML form element
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 3
138 \& use HTML::Form;
139 \& $form = HTML::Form\->parse($html, $base_uri);
140 \& $form\->value(query => "Perl");
141 .Ve
142 .PP
143 .Vb 3
144 \& use LWP::UserAgent;
145 \& $ua = LWP::UserAgent\->new;
146 \& $response = $ua\->request($form\->click);
147 .Ve
148 .SH "DESCRIPTION"
149 .IX Header "DESCRIPTION"
150 Objects of the \f(CW\*(C`HTML::Form\*(C'\fR class represents a single \s-1HTML\s0
151 \&\f(CW\*(C`<form> ... </form>\*(C'\fR instance.  A form consists of a
152 sequence of inputs that usually have names, and which can take on
153 various values.  The state of a form can be tweaked and it can then be
154 asked to provide \f(CW\*(C`HTTP::Request\*(C'\fR objects that can be passed to the
155 \&\fIrequest()\fR method of \f(CW\*(C`LWP::UserAgent\*(C'\fR.
156 .PP
157 The following methods are available:
158 .ie n .IP "@forms = HTML::Form\->parse( $html_document\fR, \f(CW$base_uri )" 4
159 .el .IP "@forms = HTML::Form\->parse( \f(CW$html_document\fR, \f(CW$base_uri\fR )" 4
160 .IX Item "@forms = HTML::Form->parse( $html_document, $base_uri )"
161 .PD 0
162 .ie n .IP "@forms = HTML::Form\->parse( $html_document\fR, base => \f(CW$base_uri\fR, \f(CW%opt )" 4
163 .el .IP "@forms = HTML::Form\->parse( \f(CW$html_document\fR, base => \f(CW$base_uri\fR, \f(CW%opt\fR )" 4
164 .IX Item "@forms = HTML::Form->parse( $html_document, base => $base_uri, %opt )"
165 .ie n .IP "@forms = HTML::Form\->parse( $response\fR, \f(CW%opt )" 4
166 .el .IP "@forms = HTML::Form\->parse( \f(CW$response\fR, \f(CW%opt\fR )" 4
167 .IX Item "@forms = HTML::Form->parse( $response, %opt )"
168 .PD
169 The \fIparse()\fR class method will parse an \s-1HTML\s0 document and build up
170 \&\f(CW\*(C`HTML::Form\*(C'\fR objects for each <form> element found.  If called in scalar
171 context only returns the first <form>.  Returns an empty list if there
172 are no forms to be found.
173 .Sp
174 The required arguments is the \s-1HTML\s0 document to parse ($html_document) and the
175 \&\s-1URI\s0 used to retrieve the document ($base_uri).  The base \s-1URI\s0 is needed to resolve
176 relative action URIs.  The provided \s-1HTML\s0 document should be a Unicode string
177 (or \s-1US\-ASCII\s0).
178 .Sp
179 By default HTML::Form assumes that the original document was \s-1UTF\-8\s0 encoded and
180 thus encode forms that don't specify an explict \fIaccept-charset\fR as \s-1UTF\-8\s0.
181 The charset assumed can be overridden by providing the \f(CW\*(C`charset\*(C'\fR option to
182 \&\fIparse()\fR.  It's a good idea to be explict about this parameter as well, thus
183 the recommended simplest invocation becomes:
184 .Sp
185 .Vb 5
186 \&    my @forms = HTML::Form\->parse(
187 \&        Encode::decode($encoding, $html_document_bytes),
188 \&        base => $base_uri,
189 \&        charset => $encoding,
190 \&    );
191 .Ve
192 .Sp
193 If the document was retrieved with \s-1LWP\s0 then the response object provide methods
194 to obtain a proper value for \f(CW\*(C`base\*(C'\fR and \f(CW\*(C`charset\*(C'\fR:
195 .Sp
196 .Vb 6
197 \&    my $ua = LWP::UserAgent\->new;
198 \&    my $response = $ua\->get("http://www.example.com/form.html");
199 \&    my @forms = HTML::Form\->parse($response\->decoded_content,
200 \&        base => $response\->base,
201 \&        charset => $response\->content_charset,
202 \&    );
203 .Ve
204 .Sp
205 In fact, the \fIparse()\fR method can parse from an \f(CW\*(C`HTTP::Response\*(C'\fR object
206 directly, so the example above can be more conveniently written as:
207 .Sp
208 .Vb 3
209 \&    my $ua = LWP::UserAgent\->new;
210 \&    my $response = $ua\->get("http://www.example.com/form.html");
211 \&    my @forms = HTML::Form\->parse($response);
212 .Ve
213 .Sp
214 Note that any object that implements a \fIdecoded_content()\fR, \fIbase()\fR and
215 \&\fIcontent_charset()\fR method with similar behaviour as \f(CW\*(C`HTTP::Response\*(C'\fR will do.
216 .Sp
217 Additional options might be passed in to control how the parse method
218 behaves.  The following are all the options currently recognized:
219 .RS 4
220 .ie n .IP """base => $uri""" 4
221 .el .IP "\f(CWbase => $uri\fR" 4
222 .IX Item "base => $uri"
223 This is the \s-1URI\s0 used to retrive the original document.  This option is not optional ;\-)
224 .ie n .IP """charset => $str""" 4
225 .el .IP "\f(CWcharset => $str\fR" 4
226 .IX Item "charset => $str"
227 Specify what charset the original document was encoded in.  This is used as
228 the default for accept_charset.  If not provided this defaults to \*(L"\s-1UTF\-8\s0\*(R".
229 .ie n .IP """verbose => $bool""" 4
230 .el .IP "\f(CWverbose => $bool\fR" 4
231 .IX Item "verbose => $bool"
232 Warn (print messages to \s-1STDERR\s0) about any bad \s-1HTML\s0 form constructs found.
233 You can trap these with \f(CW$SIG\fR{_\|_WARN_\|_}.
234 .ie n .IP """strict => $bool""" 4
235 .el .IP "\f(CWstrict => $bool\fR" 4
236 .IX Item "strict => $bool"
237 Initialize any form objects with the given strict attribute.
238 .RE
239 .RS 4
240 .RE
241 .ie n .IP "$method = $form\->method" 4
242 .el .IP "$method = \f(CW$form\fR\->method" 4
243 .IX Item "$method = $form->method"
244 .PD 0
245 .ie n .IP "$form\->method( $new_method )" 4
246 .el .IP "$form\->method( \f(CW$new_method\fR )" 4
247 .IX Item "$form->method( $new_method )"
248 .PD
249 This method is gets/sets the \fImethod\fR name used for the
250 \&\f(CW\*(C`HTTP::Request\*(C'\fR generated.  It is a string like \*(L"\s-1GET\s0\*(R" or \*(L"\s-1POST\s0\*(R".
251 .ie n .IP "$action = $form\->action" 4
252 .el .IP "$action = \f(CW$form\fR\->action" 4
253 .IX Item "$action = $form->action"
254 .PD 0
255 .ie n .IP "$form\->action( $new_action )" 4
256 .el .IP "$form\->action( \f(CW$new_action\fR )" 4
257 .IX Item "$form->action( $new_action )"
258 .PD
259 This method gets/sets the \s-1URI\s0 which we want to apply the request
260 \&\fImethod\fR to.
261 .ie n .IP "$enctype = $form\->enctype" 4
262 .el .IP "$enctype = \f(CW$form\fR\->enctype" 4
263 .IX Item "$enctype = $form->enctype"
264 .PD 0
265 .ie n .IP "$form\->enctype( $new_enctype )" 4
266 .el .IP "$form\->enctype( \f(CW$new_enctype\fR )" 4
267 .IX Item "$form->enctype( $new_enctype )"
268 .PD
269 This method gets/sets the encoding type for the form data.  It is a
270 string like \*(L"application/x\-www\-form\-urlencoded\*(R" or \*(L"multipart/form\-data\*(R".
271 .ie n .IP "$accept = $form\->accept_charset" 4
272 .el .IP "$accept = \f(CW$form\fR\->accept_charset" 4
273 .IX Item "$accept = $form->accept_charset"
274 .PD 0
275 .ie n .IP "$form\->accept_charset( $new_accept )" 4
276 .el .IP "$form\->accept_charset( \f(CW$new_accept\fR )" 4
277 .IX Item "$form->accept_charset( $new_accept )"
278 .PD
279 This method gets/sets the list of charset encodings that the server processing
280 the form accepts. Current implementation supports only one-element lists.
281 Default value is \*(L"\s-1UNKNOWN\s0\*(R" which we interpret as a request to use document
282 charset as specified by the 'charset' parameter of the \fIparse()\fR method. To
283 encode character strings you should have modern perl with Encode module. On
284 older perls the setting of this attribute has no effect.
285 .ie n .IP "$value = $form\fR\->attr( \f(CW$name )" 4
286 .el .IP "$value = \f(CW$form\fR\->attr( \f(CW$name\fR )" 4
287 .IX Item "$value = $form->attr( $name )"
288 .PD 0
289 .ie n .IP "$form\->attr( $name\fR, \f(CW$new_value )" 4
290 .el .IP "$form\->attr( \f(CW$name\fR, \f(CW$new_value\fR )" 4
291 .IX Item "$form->attr( $name, $new_value )"
292 .PD
293 This method give access to the original \s-1HTML\s0 attributes of the <form> tag.
294 The \f(CW$name\fR should always be passed in lower case.
295 .Sp
296 Example:
297 .Sp
298 .Vb 4
299 \&   @f = HTML::Form\->parse( $html, $foo );
300 \&   @f = grep $_\->attr("id") eq "foo", @f;
301 \&   die "No form named 'foo' found" unless @f;
302 \&   $foo = shift @f;
303 .Ve
304 .ie n .IP "$bool = $form\->strict" 4
305 .el .IP "$bool = \f(CW$form\fR\->strict" 4
306 .IX Item "$bool = $form->strict"
307 .PD 0
308 .ie n .IP "$form\->strict( $bool )" 4
309 .el .IP "$form\->strict( \f(CW$bool\fR )" 4
310 .IX Item "$form->strict( $bool )"
311 .PD
312 Gets/sets the strict attribute of a form.  If the strict is turned on
313 the methods that change values of the form will croak if you try to
314 set illegal values or modify readonly fields.  The default is not to be strict.
315 .ie n .IP "@inputs = $form\->inputs" 4
316 .el .IP "@inputs = \f(CW$form\fR\->inputs" 4
317 .IX Item "@inputs = $form->inputs"
318 This method returns the list of inputs in the form.  If called in
319 scalar context it returns the number of inputs contained in the form.
320 See \*(L"\s-1INPUTS\s0\*(R" for what methods are available for the input objects
321 returned.
322 .ie n .IP "$input = $form\fR\->find_input( \f(CW$selector )" 4
323 .el .IP "$input = \f(CW$form\fR\->find_input( \f(CW$selector\fR )" 4
324 .IX Item "$input = $form->find_input( $selector )"
325 .PD 0
326 .ie n .IP "$input = $form\fR\->find_input( \f(CW$selector\fR, \f(CW$type )" 4
327 .el .IP "$input = \f(CW$form\fR\->find_input( \f(CW$selector\fR, \f(CW$type\fR )" 4
328 .IX Item "$input = $form->find_input( $selector, $type )"
329 .ie n .IP "$input = $form\fR\->find_input( \f(CW$selector\fR, \f(CW$type\fR, \f(CW$index )" 4
330 .el .IP "$input = \f(CW$form\fR\->find_input( \f(CW$selector\fR, \f(CW$type\fR, \f(CW$index\fR )" 4
331 .IX Item "$input = $form->find_input( $selector, $type, $index )"
332 .PD
333 This method is used to locate specific inputs within the form.  All
334 inputs that match the arguments given are returned.  In scalar context
335 only the first is returned, or \f(CW\*(C`undef\*(C'\fR if none match.
336 .Sp
337 If \f(CW$selector\fR is specified, then the input's name, id, class attribute must
338 match.  A selector prefixed with '#' must match the id attribute of the input.
339 A selector prefixed with '.' matches the class attribute.  A selector prefixed
340 with '^' or with no prefix matches the name attribute.
341 .Sp
342 If \f(CW$type\fR is specified, then the input must have the specified type.
343 The following type names are used: \*(L"text\*(R", \*(L"password\*(R", \*(L"hidden\*(R",
344 \&\*(L"textarea\*(R", \*(L"file\*(R", \*(L"image\*(R", \*(L"submit\*(R", \*(L"radio\*(R", \*(L"checkbox\*(R" and \*(L"option\*(R".
345 .Sp
346 The \f(CW$index\fR is the sequence number of the input matched where 1 is the
347 first.  If combined with \f(CW$name\fR and/or \f(CW$type\fR then it select the \fIn\fRth
348 input with the given name and/or type.
349 .ie n .IP "$value = $form\fR\->value( \f(CW$selector )" 4
350 .el .IP "$value = \f(CW$form\fR\->value( \f(CW$selector\fR )" 4
351 .IX Item "$value = $form->value( $selector )"
352 .PD 0
353 .ie n .IP "$form\->value( $selector\fR, \f(CW$new_value )" 4
354 .el .IP "$form\->value( \f(CW$selector\fR, \f(CW$new_value\fR )" 4
355 .IX Item "$form->value( $selector, $new_value )"
356 .PD
357 The \fIvalue()\fR method can be used to get/set the value of some input.  If
358 strict is enabled and no input has the indicated name, then this method will croak.
359 .Sp
360 If multiple inputs have the same name, only the first one will be
361 affected.
362 .Sp
363 The call:
364 .Sp
365 .Vb 1
366 \&    $form\->value('foo')
367 .Ve
368 .Sp
369 is basically a short-hand for:
370 .Sp
371 .Vb 1
372 \&    $form\->find_input('foo')\->value;
373 .Ve
374 .ie n .IP "@names = $form\->param" 4
375 .el .IP "@names = \f(CW$form\fR\->param" 4
376 .IX Item "@names = $form->param"
377 .PD 0
378 .ie n .IP "@values = $form\fR\->param( \f(CW$name )" 4
379 .el .IP "@values = \f(CW$form\fR\->param( \f(CW$name\fR )" 4
380 .IX Item "@values = $form->param( $name )"
381 .ie n .IP "$form\->param( $name\fR, \f(CW$value, ... )" 4
382 .el .IP "$form\->param( \f(CW$name\fR, \f(CW$value\fR, ... )" 4
383 .IX Item "$form->param( $name, $value, ... )"
384 .ie n .IP "$form\->param( $name, \e@values )" 4
385 .el .IP "$form\->param( \f(CW$name\fR, \e@values )" 4
386 .IX Item "$form->param( $name, @values )"
387 .PD
388 Alternative interface to examining and setting the values of the form.
389 .Sp
390 If called without arguments then it returns the names of all the
391 inputs in the form.  The names will not repeat even if multiple inputs
392 have the same name.  In scalar context the number of different names
393 is returned.
394 .Sp
395 If called with a single argument then it returns the value or values
396 of inputs with the given name.  If called in scalar context only the
397 first value is returned.  If no input exists with the given name, then
398 \&\f(CW\*(C`undef\*(C'\fR is returned.
399 .Sp
400 If called with 2 or more arguments then it will set values of the
401 named inputs.  This form will croak if no inputs have the given name
402 or if any of the values provided does not fit.  Values can also be
403 provided as a reference to an array.  This form will allow unsetting
404 all values with the given name as well.
405 .Sp
406 This interface resembles that of the \fIparam()\fR function of the \s-1CGI\s0
407 module.
408 .IP "$form\->try_others( \e&callback )" 4
409 .IX Item "$form->try_others( &callback )"
410 This method will iterate over all permutations of unvisited enumerated
411 values (<select>, <radio>, <checkbox>) and invoke the callback for
412 each.  The callback is passed the \f(CW$form\fR as argument.  The return value
413 from the callback is ignored and the \fItry_others()\fR method itself does
414 not return anything.
415 .ie n .IP "$request = $form\->make_request" 4
416 .el .IP "$request = \f(CW$form\fR\->make_request" 4
417 .IX Item "$request = $form->make_request"
418 Will return an \f(CW\*(C`HTTP::Request\*(C'\fR object that reflects the current setting
419 of the form.  You might want to use the \fIclick()\fR method instead.
420 .ie n .IP "$request = $form\->click" 4
421 .el .IP "$request = \f(CW$form\fR\->click" 4
422 .IX Item "$request = $form->click"
423 .PD 0
424 .ie n .IP "$request = $form\fR\->click( \f(CW$selector )" 4
425 .el .IP "$request = \f(CW$form\fR\->click( \f(CW$selector\fR )" 4
426 .IX Item "$request = $form->click( $selector )"
427 .ie n .IP "$request = $form\fR\->click( \f(CW$x\fR, \f(CW$y )" 4
428 .el .IP "$request = \f(CW$form\fR\->click( \f(CW$x\fR, \f(CW$y\fR )" 4
429 .IX Item "$request = $form->click( $x, $y )"
430 .ie n .IP "$request = $form\fR\->click( \f(CW$selector\fR, \f(CW$x\fR, \f(CW$y )" 4
431 .el .IP "$request = \f(CW$form\fR\->click( \f(CW$selector\fR, \f(CW$x\fR, \f(CW$y\fR )" 4
432 .IX Item "$request = $form->click( $selector, $x, $y )"
433 .PD
434 Will \*(L"click\*(R" on the first clickable input (which will be of type
435 \&\f(CW\*(C`submit\*(C'\fR or \f(CW\*(C`image\*(C'\fR).  The result of clicking is an \f(CW\*(C`HTTP::Request\*(C'\fR
436 object that can then be passed to \f(CW\*(C`LWP::UserAgent\*(C'\fR if you want to
437 obtain the server response.
438 .Sp
439 If a \f(CW$selector\fR is specified, we will click on the first clickable input
440 matching the selector, and the method will croak if no matching clickable
441 input is found.  If \f(CW$selector\fR is \fInot\fR specified, then it
442 is ok if the form contains no clickable inputs.  In this case the
443 \&\fIclick()\fR method returns the same request as the \fImake_request()\fR method
444 would do.  See description of the \fIfind_input()\fR method above for how
445 the \f(CW$selector\fR is specified.
446 .Sp
447 If there are multiple clickable inputs with the same name, then there
448 is no way to get the \fIclick()\fR method of the \f(CW\*(C`HTML::Form\*(C'\fR to click on
449 any but the first.  If you need this you would have to locate the
450 input with \fIfind_input()\fR and invoke the \fIclick()\fR method on the given
451 input yourself.
452 .Sp
453 A click coordinate pair can also be provided, but this only makes a
454 difference if you clicked on an image.  The default coordinate is
455 (1,1).  The upper-left corner of the image is (0,0), but some badly
456 coded \s-1CGI\s0 scripts are known to not recognize this.  Therefore (1,1) was
457 selected as a safer default.
458 .ie n .IP "@kw = $form\->form" 4
459 .el .IP "@kw = \f(CW$form\fR\->form" 4
460 .IX Item "@kw = $form->form"
461 Returns the current setting as a sequence of key/value pairs.  Note
462 that keys might be repeated, which means that some values might be
463 lost if the return values are assigned to a hash.
464 .Sp
465 In scalar context this method returns the number of key/value pairs
466 generated.
467 .IP "$form\->dump" 4
468 .IX Item "$form->dump"
469 Returns a textual representation of current state of the form.  Mainly
470 useful for debugging.  If called in void context, then the dump is
471 printed on \s-1STDERR\s0.
472 .SH "INPUTS"
473 .IX Header "INPUTS"
474 An \f(CW\*(C`HTML::Form\*(C'\fR objects contains a sequence of \fIinputs\fR.  References to
475 the inputs can be obtained with the \f(CW$form\fR\->inputs or \f(CW$form\fR\->find_input
476 methods.
477 .PP
478 Note that there is \fInot\fR a one-to-one correspondence between input
479 \&\fIobjects\fR and <input> \fIelements\fR in the \s-1HTML\s0 document.  An
480 input object basically represents a name/value pair, so when multiple
481 \&\s-1HTML\s0 elements contribute to the same name/value pair in the submitted
482 form they are combined.
483 .PP
484 The input elements that are mapped one-to-one are \*(L"text\*(R", \*(L"textarea\*(R",
485 \&\*(L"password\*(R", \*(L"hidden\*(R", \*(L"file\*(R", \*(L"image\*(R", \*(L"submit\*(R" and \*(L"checkbox\*(R".  For
486 the \*(L"radio\*(R" and \*(L"option\*(R" inputs the story is not as simple: All
487 <input type=\*(L"radio\*(R"> elements with the same name will
488 contribute to the same input radio object.  The number of radio input
489 objects will be the same as the number of distinct names used for the
490 <input type=\*(L"radio\*(R"> elements.  For a <select> element
491 without the \f(CW\*(C`multiple\*(C'\fR attribute there will be one input object of
492 type of \*(L"option\*(R".  For a <select multiple> element there will
493 be one input object for each contained <option> element.  Each
494 one of these option objects will have the same name.
495 .PP
496 The following methods are available for the \fIinput\fR objects:
497 .IP "$input\->type" 4
498 .IX Item "$input->type"
499 Returns the type of this input.  The type is one of the following
500 strings: \*(L"text\*(R", \*(L"password\*(R", \*(L"hidden\*(R", \*(L"textarea\*(R", \*(L"file\*(R", \*(L"image\*(R", \*(L"submit\*(R",
501 \&\*(L"radio\*(R", \*(L"checkbox\*(R" or \*(L"option\*(R".
502 .ie n .IP "$name = $input\->name" 4
503 .el .IP "$name = \f(CW$input\fR\->name" 4
504 .IX Item "$name = $input->name"
505 .PD 0
506 .ie n .IP "$input\->name( $new_name )" 4
507 .el .IP "$input\->name( \f(CW$new_name\fR )" 4
508 .IX Item "$input->name( $new_name )"
509 .PD
510 This method can be used to get/set the current name of the input.
511 .IP "$input\->id" 4
512 .IX Item "$input->id"
513 .PD 0
514 .IP "$input\->class" 4
515 .IX Item "$input->class"
516 .PD
517 These methods can be used to get/set the current id or class attribute for the input.
518 .ie n .IP "$input\->selected( $selector )" 4
519 .el .IP "$input\->selected( \f(CW$selector\fR )" 4
520 .IX Item "$input->selected( $selector )"
521 Returns \s-1TRUE\s0 if the given selector matched the input.  See the description of
522 the \fIfind_input()\fR method above for a description of the selector syntax.
523 .ie n .IP "$value = $input\->value" 4
524 .el .IP "$value = \f(CW$input\fR\->value" 4
525 .IX Item "$value = $input->value"
526 .PD 0
527 .ie n .IP "$input\->value( $new_value )" 4
528 .el .IP "$input\->value( \f(CW$new_value\fR )" 4
529 .IX Item "$input->value( $new_value )"
530 .PD
531 This method can be used to get/set the current value of an
532 input.
533 .Sp
534 If strict is enabled and the input only can take an enumerated list of values,
535 then it is an error to try to set it to something else and the method will
536 croak if you try.
537 .Sp
538 You will also be able to set the value of read-only inputs, but a
539 warning will be generated if running under \f(CW\*(C`perl \-w\*(C'\fR.
540 .IP "$input\->possible_values" 4
541 .IX Item "$input->possible_values"
542 Returns a list of all values that an input can take.  For inputs that
543 do not have discrete values, this returns an empty list.
544 .IP "$input\->other_possible_values" 4
545 .IX Item "$input->other_possible_values"
546 Returns a list of all values not tried yet.
547 .IP "$input\->value_names" 4
548 .IX Item "$input->value_names"
549 For some inputs the values can have names that are different from the
550 values themselves.  The number of names returned by this method will
551 match the number of values reported by \f(CW$input\fR\->possible_values.
552 .Sp
553 When setting values using the \fIvalue()\fR method it is also possible to
554 use the value names in place of the value itself.
555 .ie n .IP "$bool = $input\->readonly" 4
556 .el .IP "$bool = \f(CW$input\fR\->readonly" 4
557 .IX Item "$bool = $input->readonly"
558 .PD 0
559 .ie n .IP "$input\->readonly( $bool )" 4
560 .el .IP "$input\->readonly( \f(CW$bool\fR )" 4
561 .IX Item "$input->readonly( $bool )"
562 .PD
563 This method is used to get/set the value of the readonly attribute.
564 You are allowed to modify the value of readonly inputs, but setting
565 the value will generate some noise when warnings are enabled.  Hidden
566 fields always start out readonly.
567 .ie n .IP "$bool = $input\->disabled" 4
568 .el .IP "$bool = \f(CW$input\fR\->disabled" 4
569 .IX Item "$bool = $input->disabled"
570 .PD 0
571 .ie n .IP "$input\->disabled( $bool )" 4
572 .el .IP "$input\->disabled( \f(CW$bool\fR )" 4
573 .IX Item "$input->disabled( $bool )"
574 .PD
575 This method is used to get/set the value of the disabled attribute.
576 Disabled inputs do not contribute any key/value pairs for the form
577 value.
578 .IP "$input\->form_name_value" 4
579 .IX Item "$input->form_name_value"
580 Returns a (possible empty) list of key/value pairs that should be
581 incorporated in the form value from this input.
582 .IP "$input\->check" 4
583 .IX Item "$input->check"
584 Some input types represent toggles that can be turned on/off.  This
585 includes \*(L"checkbox\*(R" and \*(L"option\*(R" inputs.  Calling this method turns
586 this input on without having to know the value name.  If the input is
587 already on, then nothing happens.
588 .Sp
589 This has the same effect as:
590 .Sp
591 .Vb 1
592 \&    $input\->value($input\->possible_values[1]);
593 .Ve
594 .Sp
595 The input can be turned off with:
596 .Sp
597 .Vb 1
598 \&    $input\->value(undef);
599 .Ve
600 .ie n .IP "$input\->click($form, $x\fR, \f(CW$y)" 4
601 .el .IP "$input\->click($form, \f(CW$x\fR, \f(CW$y\fR)" 4
602 .IX Item "$input->click($form, $x, $y)"
603 Some input types (currently \*(L"submit\*(R" buttons and \*(L"images\*(R") can be
604 clicked to submit the form.  The \fIclick()\fR method returns the
605 corresponding \f(CW\*(C`HTTP::Request\*(C'\fR object.
606 .PP
607 If the input is of type \f(CW\*(C`file\*(C'\fR, then it has these additional methods:
608 .IP "$input\->file" 4
609 .IX Item "$input->file"
610 This is just an alias for the \fIvalue()\fR method.  It sets the filename to
611 read data from.
612 .Sp
613 For security reasons this field will never be initialized from the parsing
614 of a form.  This prevents the server from triggering stealth uploads of
615 arbitrary files from the client machine.
616 .ie n .IP "$filename = $input\->filename" 4
617 .el .IP "$filename = \f(CW$input\fR\->filename" 4
618 .IX Item "$filename = $input->filename"
619 .PD 0
620 .ie n .IP "$input\->filename( $new_filename )" 4
621 .el .IP "$input\->filename( \f(CW$new_filename\fR )" 4
622 .IX Item "$input->filename( $new_filename )"
623 .PD
624 This get/sets the filename reported to the server during file upload.
625 This attribute defaults to the value reported by the \fIfile()\fR method.
626 .ie n .IP "$content = $input\->content" 4
627 .el .IP "$content = \f(CW$input\fR\->content" 4
628 .IX Item "$content = $input->content"
629 .PD 0
630 .ie n .IP "$input\->content( $new_content )" 4
631 .el .IP "$input\->content( \f(CW$new_content\fR )" 4
632 .IX Item "$input->content( $new_content )"
633 .PD
634 This get/sets the file content provided to the server during file
635 upload.  This method can be used if you do not want the content to be
636 read from an actual file.
637 .ie n .IP "@headers = $input\->headers" 4
638 .el .IP "@headers = \f(CW$input\fR\->headers" 4
639 .IX Item "@headers = $input->headers"
640 .PD 0
641 .ie n .IP "input\->headers($key => $value, .... )" 4
642 .el .IP "input\->headers($key => \f(CW$value\fR, .... )" 4
643 .IX Item "input->headers($key => $value, .... )"
644 .PD
645 This get/set additional header fields describing the file uploaded.
646 This can for instance be used to set the \f(CW\*(C`Content\-Type\*(C'\fR reported for
647 the file.
648 .SH "SEE ALSO"
649 .IX Header "SEE ALSO"
650 \&\s-1LWP\s0, LWP::UserAgent, HTML::Parser
651 .SH "COPYRIGHT"
652 .IX Header "COPYRIGHT"
653 Copyright 1998\-2008 Gisle Aas.
654 .PP
655 This library is free software; you can redistribute it and/or
656 modify it under the same terms as Perl itself.