Skip to content

Commit 0e82552

Browse files
committedOct 3, 2011
Make a custom getEditTemplate method to handle getting information from the parent Matrix. Fix class=>className form code, and adding buttons.
1 parent 259a42b commit 0e82552

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed
 

‎lib/WebGUI/Asset/MatrixListing.pm

+25-31
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ sub getEditForm {
217217
value => 'new',
218218
);
219219
$form->addField( "hidden",
220-
name => 'class',
220+
name => 'className',
221221
value => 'WebGUI::Asset::MatrixListing',
222222
);
223223
}
@@ -324,18 +324,39 @@ sub getEditForm {
324324
}
325325

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

334334
return $form;
335335
}
336336

337337
#-------------------------------------------------------------------
338338

339+
=head2 getEditTemplate ( )
340+
341+
Override the base method to get the template from the parent Matrix asset.
342+
343+
=cut
344+
345+
sub getEditTemplate {
346+
my $self = shift;
347+
my $var = $self->get;
348+
my $matrix = $self->getParent;
349+
my $template = eval { WebGUI::Asset->newById($self->session, $matrix->get('editListingTemplateId')); };
350+
# TODO: Change to FormBuilder
351+
$var->{form} = $self->getEditForm->toHtml;
352+
$self->session->log->warn($var->{form});
353+
$template->setParam(%{ $var });
354+
$template->style($matrix->getStyleTemplateId);
355+
return $template;
356+
}
357+
358+
#-------------------------------------------------------------------
359+
339360
=head2 hasRated ( )
340361
341362
Returns whether the user has already rated this listing or not.
@@ -813,33 +834,6 @@ sub www_deleteStickied {
813834

814835
#-------------------------------------------------------------------
815836

816-
=head2 www_edit ( )
817-
818-
Web facing method which is the default edit page
819-
820-
=cut
821-
822-
sub www_edit {
823-
my $self = shift;
824-
my $i18n = WebGUI::International->new($self->session, "Asset_MatrixListing");
825-
826-
if($self->session->form->process('func') eq 'add'){
827-
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
828-
}else{
829-
return $self->session->privilege->insufficient() unless $self->canEdit;
830-
return $self->session->privilege->locked() unless $self->canEditIfLocked;
831-
}
832-
833-
my $var = $self->get;
834-
my $matrix = $self->getParent;
835-
# TODO: Change to FormBuilder
836-
$var->{form} = $self->getEditForm->toHtml;
837-
838-
return $matrix->processStyle($self->processTemplate($var,$matrix->get("editListingTemplateId")));
839-
}
840-
841-
#-------------------------------------------------------------------
842-
843837
=head2 www_getAttributes ( )
844838
845839
Gets a listings attributes grouped by category as json.

0 commit comments

Comments
 (0)
Please sign in to comment.