migrate PayDriver getEditForm to FormBuilder
This commit is contained in:
parent
3ce8498427
commit
71261438f7
4 changed files with 102 additions and 33 deletions
|
|
@ -328,7 +328,7 @@ sub www_manage {
|
|||
.WebGUI::Form::hidden($session, { name => "shop", value => "pay" })
|
||||
.WebGUI::Form::hidden($session, { name => "method", value => "addPaymentGateway" })
|
||||
.WebGUI::Form::selectBox($session, { name => "className", options => $self->getDrivers })
|
||||
.WebGUI::Form::submit($session, { value => $i18n->get("add payment method") })
|
||||
.WebGUI::Form::submit($session, { name => "add", value => $i18n->get("add payment method") })
|
||||
.WebGUI::Form::formFooter($session);
|
||||
|
||||
# Add a row with edit/delete buttons for each payment gateway.
|
||||
|
|
@ -339,7 +339,7 @@ sub www_manage {
|
|||
.WebGUI::Form::hidden($session, { name => "shop", value => "pay" })
|
||||
.WebGUI::Form::hidden($session, { name => "method", value => "deletePaymentGateway" })
|
||||
.WebGUI::Form::hidden($session, { name => "paymentGatewayId", value => $paymentGateway->getId })
|
||||
.WebGUI::Form::submit($session, { value => $i18n->get("delete"), extras => 'class="backwardButton"' })
|
||||
.WebGUI::Form::submit($session, { name => 'delete', value => $i18n->get("delete"), extras => 'class="backwardButton"' })
|
||||
.WebGUI::Form::formFooter($session)
|
||||
|
||||
# Edit button for current payment gateway
|
||||
|
|
@ -348,7 +348,7 @@ sub www_manage {
|
|||
.WebGUI::Form::hidden($session, { name => "method", value => "do" })
|
||||
.WebGUI::Form::hidden($session, { name => "do", value => "edit" })
|
||||
.WebGUI::Form::hidden($session, { name => "paymentGatewayId", value => $paymentGateway->getId })
|
||||
.WebGUI::Form::submit($session, { value => $i18n->get("edit"), extras => 'class="normalButton"' })
|
||||
.WebGUI::Form::submit($session, { name => 'edit', value => $i18n->get("edit"), extras => 'class="normalButton"' })
|
||||
.WebGUI::Form::formFooter($session)
|
||||
|
||||
# Append payment gateway label
|
||||
|
|
|
|||
|
|
@ -318,30 +318,28 @@ sub getCart {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDoFormTags ( $method, $htmlForm )
|
||||
=head2 getDoFormTags ( $method, $fb )
|
||||
|
||||
Returns a string containing the required form fields for doing a www_do method call. If an HTMLForm object is
|
||||
Returns a string containing the required form fields for doing a www_do method call. If a FormBuilder object is
|
||||
passed the fields are automatically added to it. In that case no form tags a returned by this method.
|
||||
|
||||
=head3 $htmlForm
|
||||
=head3 $fb
|
||||
|
||||
The HTMLForm object you want to add the fields to. This is optional.
|
||||
The FormBuilder object you want to add the fields to. This is optional.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDoFormTags {
|
||||
my $self = shift;
|
||||
my $doMethod = shift;
|
||||
my $htmlForm = shift;
|
||||
my $fb = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
if ($htmlForm) {
|
||||
$htmlForm->hidden(name => 'shop', value => 'pay');
|
||||
$htmlForm->hidden(name => 'method', value => 'do');
|
||||
$htmlForm->hidden(name => 'do', value => $doMethod);
|
||||
$htmlForm->hidden(name => 'paymentGatewayId', value => $self->getId);
|
||||
|
||||
return undef;
|
||||
if ($fb) {
|
||||
$fb->addField( "hidden", name => 'shop', value => 'pay');
|
||||
$fb->addField( "hidden", name => 'method', value => 'do');
|
||||
$fb->addField( "hidden", name => 'do', value => $doMethod);
|
||||
$fb->addField( "hidden", name => 'paymentGatewayId', value => $self->getId);
|
||||
}
|
||||
else {
|
||||
return WebGUI::Form::hidden($session, { name => 'shop', value => 'pay' })
|
||||
|
|
@ -363,24 +361,23 @@ Returns the configuration form for the options of this plugin.
|
|||
sub getEditForm {
|
||||
my $self = shift;
|
||||
|
||||
my $form = WebGUI::HTMLForm->new($self->session);
|
||||
$form->submit;
|
||||
my $form = WebGUI::FormBuilder->new($self->session);
|
||||
$form->addField( "submit", name => "submit" );
|
||||
|
||||
$self->getDoFormTags('editSave', $form);
|
||||
$form->hidden(
|
||||
$form->addField( "hidden",
|
||||
name => 'className',
|
||||
value => $self->className,
|
||||
);
|
||||
tie my %form_options, 'Tie::IxHash';
|
||||
foreach my $property_name ($self->getProperties) {
|
||||
my $property = $self->meta->find_attribute_by_name($property_name);
|
||||
$form_options{$property_name} = {
|
||||
my %form_options = (
|
||||
name => $property_name,
|
||||
value => $self->$property_name,
|
||||
%{ $self->getFormProperties($property_name)},
|
||||
};
|
||||
);
|
||||
$form->addField( delete $form_options{ fieldType }, %form_options );
|
||||
}
|
||||
my $definition = [ { properties => \%form_options }, ];
|
||||
$form->dynamicForm($definition, 'properties', $self);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -651,9 +648,10 @@ sub www_edit {
|
|||
return $session->privilege->insufficient() unless $session->user->isAdmin;
|
||||
|
||||
my $form = $self->getEditForm;
|
||||
$form->submit;
|
||||
$form->addField( 'csrfToken', name => 'csrfToken' );
|
||||
$form->addField( "submit", name => "submit" );
|
||||
|
||||
return $admin->getAdminConsole->render($form->print, $i18n->get('payment methods'));
|
||||
return '<h1>' . $i18n->get('payment methods') . '</h1>' . $form->toHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue