Require that the user be logged in before entering in address info. Refactor out address form into a method that can called multiple times.
This commit is contained in:
parent
747fa8c922
commit
fbefeaf621
5 changed files with 131 additions and 85 deletions
|
|
@ -185,6 +185,58 @@ sub getAddresses {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAddressFormVars ( $properties, $prefix )
|
||||
|
||||
Return a hashref of template variables for building a form to edit an address.
|
||||
|
||||
=head3 $properties
|
||||
|
||||
A hash ref of properties to assign to as default to the form variables.
|
||||
|
||||
=head3 $prefix
|
||||
|
||||
An optional prefix to add to each variable name, and form name.
|
||||
|
||||
=cut
|
||||
|
||||
sub getAddressFormVars {
|
||||
my ($self, $prefix, $properties ) = @_;
|
||||
my $session = $self->session;
|
||||
$properties ||= {};
|
||||
$prefix ||= '';
|
||||
my $var = {};
|
||||
for ( qw{ address1 address2 address3 label firstName lastName city state organization } ) {
|
||||
$var->{ $prefix . $_ . 'Field' } = WebGUI::Form::text( $session, {
|
||||
name => $prefix . $_,
|
||||
maxlength => 35,
|
||||
defaultValue => $properties->{ $_ }
|
||||
} );
|
||||
}
|
||||
$var->{ $prefix . 'countryField' } =
|
||||
WebGUI::Form::country( $session,{
|
||||
name => $prefix . 'country',
|
||||
defaultValue => $properties->{ country }
|
||||
} );
|
||||
$var->{ $prefix . 'codeField' } =
|
||||
WebGUI::Form::zipcode( $session, {
|
||||
name => $prefix . 'code',
|
||||
defaultValue => $properties->{ code }
|
||||
} );
|
||||
$var->{ $prefix . 'phoneNumberField' } =
|
||||
WebGUI::Form::phone( $session, {
|
||||
name => $prefix . 'phoneNumber',
|
||||
defaultValue => $properties->{ phoneNumber }
|
||||
} );
|
||||
$var->{ $prefix . 'emailField' } =
|
||||
WebGUI::Form::email( $session, {
|
||||
name => $prefix . 'email',
|
||||
defaultValue => $properties->{ email }
|
||||
} );
|
||||
return $var;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefaultAddress ()
|
||||
|
||||
Returns the default address for this address book if there is one. Otherwise throws a WebGUI::Error::ObjectNotFound exception.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue