From e4de128f7649dbc25e376e6907e707814747f547 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 24 Nov 2011 10:31:10 -0800 Subject: [PATCH] Fix the WikiPage title auto fill-in by using a Moose builder method that can be overridden by child classes. --- lib/WebGUI/Asset.pm | 8 +++++++- lib/WebGUI/Asset/WikiPage.pm | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 1649f046a..c7cdb3985 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -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; diff --git a/lib/WebGUI/Asset/WikiPage.pm b/lib/WebGUI/Asset/WikiPage.pm index ec3eefa19..693d78542 100644 --- a/lib/WebGUI/Asset/WikiPage.pm +++ b/lib/WebGUI/Asset/WikiPage.pm @@ -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'; @@ -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" })