Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix the WikiPage title auto fill-in by using a Moose builder method t…
…hat can be overridden by child classes.
  • Loading branch information
perlDreamer committed Nov 24, 2011
1 parent ce15690 commit e4de128
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/WebGUI/Asset.pm
Expand Up @@ -33,8 +33,14 @@ property title => (
label => ['99','Asset'],
hoverHelp => ['99 description','Asset'],
fieldType => 'text',
default => 'Untitled',
builder => '_default_title',
lazy => 1,
);

sub _default_title {
return 'Untitled';
}

around title => sub {
my $orig = shift;
my $self = shift;
Expand Down
8 changes: 8 additions & 0 deletions lib/WebGUI/Asset/WikiPage.pm
Expand Up @@ -51,6 +51,12 @@ property isFeatured => (
noFormPost => 1,
);

override _default_title => sub {
my $self = shift;
my $title = $self->session->form->get('title') || super();
return $title;
};

with 'WebGUI::Role::Asset::AlwaysHidden';
with 'WebGUI::Role::Asset::Subscribable';
with 'WebGUI::Role::Asset::Comments';
Expand Down Expand Up @@ -193,6 +199,8 @@ sub getEditTemplate {
protectQuestionLabel => $i18n->get("protectQuestionLabel"),
isProtected => $self->isProtected
};
$session->log->warn("title form variable". $form->get('title', 'text'));
$session->log->warn("title form element". $var->{formTitle});
my $children = [];
if ($self->getId eq "new") {
$var->{formHeader} .= WebGUI::Form::hidden($session, { name=>"assetId", value=>"new" })
Expand Down

0 comments on commit e4de128

Please sign in to comment.