Form-Processor

 view release on metacpan or  search on metacpan

lib/Form/Processor.pm  view on Meta::CPAN

    my $form = shift;
    require Data::UUID;
    my $uuid = Data::UUID->new->create_str;
    return qq[<input type="hidden" name="form_uuid" value="$uuid">];
}



sub parent_field {
    my $self = shift;
    return Scalar::Util::weaken( $self->{parent_field} = shift ) if ( @_ );
    return $self->{parent_field};
}





1;

__END__

lib/Form/Processor.pm  view on Meta::CPAN

One way to create a compound field -- a field that is composed of
other fields -- is by having the field include a form that is made up of
fields.  For example, a date field might be made up of a form that includes
fields for the day, month, and year.

If a form has a parent_field associated with it then any errors will be pushed
onto the parent_field instead of the current field.  In the date example, an error
in the year field will cause the error to be assigned to the date field, not directly
on the year field.

This stores a weakened value.

=back

=head1 CREATING A MODEL CLASS

Form model classes are used to moved form data between a
database and the form, typically via an object relational
mapping tool (ORM).

See L<Form::Processor::Model> for details.

lib/Form/Processor/Field.pm  view on Meta::CPAN


    my $name   = $field->name;
    my $form   = $field->form || return $name;
    my $parent = $form->parent_field || return $name;
    return $parent->name . '.' . $name;
}


sub form {
    my $self = shift;
    return Scalar::Util::weaken( $self->{form} = shift ) if ( @_ );
    return $self->{form};
}


sub init_id {
    my $field = shift;
    my $form_name = $field->form ? $field->form->name : 'fld-';
    return $field->form->name . $field->name
}

lib/Form/Processor/Field.pm  view on Meta::CPAN

=item full_name

This returns the name of the field, but if the field
is a child field will prepend the field with the parent's field
name.  For example, if a field is "month" and the parent's field name
is "birthday" then this will return "birthday.month".

=item form

This is a reference to the parent form object.
It's stored weakened references.

=item sub_form

A single field can be represented by more than one sub-fields
contained in a form.  This is a reference to that form.

=item id

Returns an id for the field, which is by default:



( run in 0.878 second using v1.01-cache-2.11-cpan-65fba6d93b7 )