NAME
HTML::SuperForm::Field - HTML form field base class
SYNOPSIS
package myForm::SuperDuper;
use base 'HTML::SuperForm::Field';
sub init {}
sub prepare {}
sub to_html {
my $self = shift;
my $tag = qq|For some reason this text makes|;
$tag.= qq|the field super duper|
$tag.= qq|<input type="text" name="| . $self->name . '"';
$tag.= qq| value="| . $self->value . '"';
$tag.= '/' if $self->well_formed;
$tag.= '>';
return $tag;
}
1;
DESCRIPTION
This is the base class for all the HTML form field objects.
METHODS
CONSTRUCTOR
- new($form, %args), new($form, \%args), new(%args), new(\%args)
-
$form is the HTML::SuperForm object to associate the field with. %args usually has the following (each is also a method to access its value):
- name()
-
The name of the field.
- default()
-
The default value to use before data has been submitted or if the form isn't sticky.
Other possible arguments include:
- sticky()
-
Determines whether the field is sticky or not. Defaults to what the form object's sticky flag is set to. If no form object is specified it defaults to false.
- fallback()
-
Determines whether the field's value "falls back" to the default if the field is sticky but no data has been submitted for the field. Defaults to what the form object's fallback flag is set to. If no form object is specified it defaults to false.
- well_formed()
-
Determines whether the HTML generated is well-formed or not. If true, a slash is added to the end of non-container tags (i.e. <input type="text name="my_text"/>). Attributes such as multiple, readonly, disabled, selected, and checked are also set equal to true values instead of being left alone (i.e. <input type="checkbox" checked="checked"> rather than just <input type="checkbox" checked>).
- values_as_labels(), value_as_label()
-
Determines whether the value specifed by value or values is used as a label if no label is specified. Default is true.
- disabled()
-
Determines whether the field is disabled or not.
Arguments not used by all the fields also include:
- init($config)
-
This method is the very first thing called in HTML::SuperForm::Field's constructor. Subclasses of HTML::SuperForm::Field should override this method to manipulate the parameters passed in before processing them. An example is in HTML::SuperForm::Field::Checkbox.
- prepare()
-
This method is the very last thing called in HTML::SuperForm::Field's constructor. Subclasses of HTML::SuperForm::Field should override this method to add extra information to the object for later use. An example of its use is in the documentation for HTML::SuperForm under the section EXAMPLES.
- to_html()
-
This method returns the string representation of your field. When the object is used in string context this method is called to generate the string. Subclasses of HTML::SuperForm::Field should override this method display a default layout. All of the basic fields that come with HTML::SuperForm have this method, so look at them for examples. The Counter example in HTML::SuperForm's documentation could also be helpful.
SEE ALSO
HTML::SuperForm::Field::Text,
HTML::SuperForm::Field::Textarea,
HTML::SuperForm::Field::Select,
HTML::SuperForm::Field::Checkbox,
HTML::SuperForm::Field::Radio,
HTML::SuperForm::Field::CheckboxGroup,
HTML::SuperForm::Field::RadioGroup
AUTHOR
John Allwine <jallwine86@yahoo.com>
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 495:
'=item' outside of any '=over'
- Around line 516:
You forgot a '=back' before '=head1'