Skip to content
Permalink
Browse files

Make a custom getEditTemplate method to handle getting information fr…

…om the parent Matrix. Fix class=>className form code, and adding buttons.
  • Loading branch information...
perlDreamer committed Oct 3, 2011
1 parent 259a42b commit 0e82552f27fab353ff3ef4499accc56898cfda96
Showing with 25 additions and 31 deletions.
  1. +25 −31 lib/WebGUI/Asset/MatrixListing.pm
@@ -217,7 +217,7 @@ sub getEditForm {
value => 'new',
);
$form->addField( "hidden",
name => 'class',
name => 'className',
value => 'WebGUI::Asset::MatrixListing',
);
}
@@ -324,18 +324,39 @@ sub getEditForm {
}

my $buttons = $form->addField( "ButtonGroup", name => "saveButtons", rowClass => "saveButtons" );
$buttons->addButton( "Submit", name => "send" );
$buttons->addButton( "Button",
$buttons->addButton( "Submit", { name => "send", });
$buttons->addButton( "Button", {
name => "cancel",
value => $i18n->get('cancel', 'WebGUI'),
extras => q{onclick="history.go(-1);" class="backwardButton"},
);
} );

return $form;
}

#-------------------------------------------------------------------

=head2 getEditTemplate ( )
Override the base method to get the template from the parent Matrix asset.
=cut

sub getEditTemplate {
my $self = shift;
my $var = $self->get;
my $matrix = $self->getParent;
my $template = eval { WebGUI::Asset->newById($self->session, $matrix->get('editListingTemplateId')); };
# TODO: Change to FormBuilder
$var->{form} = $self->getEditForm->toHtml;
$self->session->log->warn($var->{form});
$template->setParam(%{ $var });
$template->style($matrix->getStyleTemplateId);
return $template;
}

#-------------------------------------------------------------------

=head2 hasRated ( )
Returns whether the user has already rated this listing or not.
@@ -813,33 +834,6 @@ sub www_deleteStickied {

#-------------------------------------------------------------------

=head2 www_edit ( )
Web facing method which is the default edit page
=cut

sub www_edit {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, "Asset_MatrixListing");

if($self->session->form->process('func') eq 'add'){
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
}else{
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->locked() unless $self->canEditIfLocked;
}

my $var = $self->get;
my $matrix = $self->getParent;
# TODO: Change to FormBuilder
$var->{form} = $self->getEditForm->toHtml;

return $matrix->processStyle($self->processTemplate($var,$matrix->get("editListingTemplateId")));
}

#-------------------------------------------------------------------

=head2 www_getAttributes ( )
Gets a listings attributes grouped by category as json.

0 comments on commit 0e82552

Please sign in to comment.
You can’t perform that action at this time.