Jifty
view release on metacpan or search on metacpan
lib/Jifty/Web/Form/Field.pm view on Meta::CPAN
=head2 disable_autocomplete [VALUE]
Gets or sets whether to disable _browser_ autocomplete for this field.
=head2 preamble [VALUE]
Gets or sets the preamble located in front of the field.
=head2 multiple [VALUE]
A boolean indicating that the field is multiple.
aka. has multiple attribute, which is useful for select field.
=head2 id
For the purposes of L<Jifty::Web::Form::Element>, the unique id of
this field is its input name.
=head2 attributes
If the field object is generated by L<Jifty::Action::Record>, this
holds the additional attributes declared to the corresponding column
of the model.
=cut
sub id {
my $self = shift;
return $self->input_name;
}
=head2 input_name [VALUE]
Gets or sets the form field input name, as it is rendered in the HTML.
If we've been explicitly named, return that, otherwise return a name
based on the moniker of the action and the name of the form.
=cut
sub input_name {
my $self = shift;
# If we've been explicitly handed a name, we should run with it.
# Otherwise, we should ask our action, how to turn our "name"
# into a form input name.
my $ret = $self->_input_name(@_);
return $ret if $ret;
my $action = $self->action;
return $action ? $self->action->form_field_name( $self->name )
: '';
}
=head2 fallback_name
Return the form field's fallback name. This should be used to create a
hidden input with a value of 0 to accompany checkboxes or to let
comboboxes fall back to the text input if, and only if no value is
selected from the SELECT. (We use this order, so that we can stick the
label and not the value in the INPUT field. To make that work, we also need
to clear the SELECT after the user types in the INPUT.
=cut
sub fallback_name {
my $self = shift;
if ($self->action) {
return $self->action->fallback_form_field_name( $self->name );
}
else {
# XXX TODO, we should have a more graceful way to compose these in the absence of an action
my $name = $self->input_name;
$name =~ s/^J:A:F/J:A:F:F/;
return($name)
}
}
=head2 label [VALUE]
Gets or sets the label on the field. This defaults to the name of the
object.
=cut
sub label {
my $self = shift;
my $val = $self->_label(@_);
defined $val ? $val : $self->name;
}
=head2 hints [VALUE]
Hints for the user to explain this field
=cut
sub hints {
my $self = shift;
return $self->_hints_accessor unless @_;
my $hint = shift;
# people sometimes say hints are "foo" rather than hints is "foo"
if (ref $hint eq 'ARRAY') {
$hint = shift @$hint;
}
return $self->_hints_accessor($hint);
}
=head2 element_id
Returns a unique C<id> attribute for this field based on the field name. This is
consistent for the life of the L<Jifty::Web::Form::Field> object but isn't predictable;
=cut
( run in 2.887 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )