migrate ship getEditForm to FormBuilder
This commit is contained in:
parent
209a24d985
commit
1d8b1b1b3a
4 changed files with 100 additions and 28 deletions
|
|
@ -273,7 +273,7 @@ sub www_manage {
|
|||
.WebGUI::Form::hidden($session, {name=>"shop", value=>"ship"})
|
||||
.WebGUI::Form::hidden($session, {name=>"method", value=>"addDriver"})
|
||||
.WebGUI::Form::selectBox($session, {name=>"className", options=>$self->getDrivers})
|
||||
.WebGUI::Form::submit($session, {value=>$i18n->get("add shipper")})
|
||||
.WebGUI::Form::submit($session, {name => 'add', value=>$i18n->get("add shipper")})
|
||||
.WebGUI::Form::formFooter($session);
|
||||
my $hasShipper = 0;
|
||||
foreach my $shipper (@{$self->getShippers}) {
|
||||
|
|
@ -282,14 +282,14 @@ sub www_manage {
|
|||
.WebGUI::Form::hidden($session, {name=>"shop", value=>"ship"})
|
||||
.WebGUI::Form::hidden($session, {name=>"method", value=>"deleteDriver"})
|
||||
.WebGUI::Form::hidden($session, {name=>"driverId", value=>$shipper->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)
|
||||
.WebGUI::Form::formHeader($session, {extras=>'style="float: left;"'})
|
||||
.WebGUI::Form::hidden($session, {name=>"shop", value=>"ship"})
|
||||
.WebGUI::Form::hidden($session, {name=>"method", value=>"do"})
|
||||
.WebGUI::Form::hidden($session, {name=>"do", value=>"edit"})
|
||||
.WebGUI::Form::hidden($session, {name=>"driverId", value=>$shipper->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)
|
||||
.' '
|
||||
.$shipper->get("label")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use strict;
|
|||
use Carp qw(croak);
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::FormBuilder;
|
||||
use WebGUI::Exception::Shop;
|
||||
use JSON;
|
||||
|
||||
|
|
@ -199,27 +199,26 @@ Returns the configuration form for the options of this plugin.
|
|||
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
|
||||
my $form = WebGUI::HTMLForm->new($self->session);
|
||||
$form->submit;
|
||||
|
||||
$form->hidden(name => 'shop',value => "ship");
|
||||
$form->hidden(name => 'method',value => "do");
|
||||
$form->hidden(name => 'do',value => "editSave");
|
||||
$form->hidden(
|
||||
|
||||
my $form = WebGUI::FormBuilder->new($self->session, action => $self->session->url->page );
|
||||
$form->addField( "submit", name => "submit" );
|
||||
|
||||
$form->addField( "hidden", name => 'shop', value => "ship");
|
||||
$form->addField( "hidden", name => 'method', value => "do");
|
||||
$form->addField( "hidden", name => 'do', value => "editSave");
|
||||
$form->addField( "hidden",
|
||||
name => 'driverId',
|
||||
value => $self->getId,
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
|
@ -329,8 +328,9 @@ sub www_edit {
|
|||
my $admin = WebGUI::Shop::Admin->new($session);
|
||||
my $i18n = WebGUI::International->new($session, "Shop");
|
||||
my $form = $self->getEditForm;
|
||||
$form->submit;
|
||||
return $admin->getAdminConsole->render($form->print, $i18n->get("shipping methods"));
|
||||
$form->addField( "submit", name => "submit" );
|
||||
$form->addField( 'csrfToken', name => 'webguiCsrfToken' );
|
||||
return '<h1>' . $i18n->get("shipping methods") . '</h1>' . $form->toHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue