Skip to content

Commit e4de128

Browse files
committedNov 24, 2011
Fix the WikiPage title auto fill-in by using a Moose builder method that can be overridden by child classes.
1 parent ce15690 commit e4de128

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎lib/WebGUI/Asset.pm

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ property title => (
3333
label => ['99','Asset'],
3434
hoverHelp => ['99 description','Asset'],
3535
fieldType => 'text',
36-
default => 'Untitled',
36+
builder => '_default_title',
37+
lazy => 1,
3738
);
39+
40+
sub _default_title {
41+
return 'Untitled';
42+
}
43+
3844
around title => sub {
3945
my $orig = shift;
4046
my $self = shift;

‎lib/WebGUI/Asset/WikiPage.pm

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ property isFeatured => (
5151
noFormPost => 1,
5252
);
5353

54+
override _default_title => sub {
55+
my $self = shift;
56+
my $title = $self->session->form->get('title') || super();
57+
return $title;
58+
};
59+
5460
with 'WebGUI::Role::Asset::AlwaysHidden';
5561
with 'WebGUI::Role::Asset::Subscribable';
5662
with 'WebGUI::Role::Asset::Comments';
@@ -193,6 +199,8 @@ sub getEditTemplate {
193199
protectQuestionLabel => $i18n->get("protectQuestionLabel"),
194200
isProtected => $self->isProtected
195201
};
202+
$session->log->warn("title form variable". $form->get('title', 'text'));
203+
$session->log->warn("title form element". $var->{formTitle});
196204
my $children = [];
197205
if ($self->getId eq "new") {
198206
$var->{formHeader} .= WebGUI::Form::hidden($session, { name=>"assetId", value=>"new" })

0 commit comments

Comments
 (0)
Please sign in to comment.