From 6964c2f1d26705db652730134865690ecf5ff1f5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 5 Jan 2009 16:49:23 +0000 Subject: [PATCH] Fix linking to other things and autocreating the form field for it. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/Thingy.pm | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 23d3d6581..675e99210 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -25,6 +25,7 @@ - fixed #9387: Asset Manager breaks navigating into a Gallery Album - fixed #9001: Thingy add image broken - fixed #9386: Gallery: "Image resolutions" issue + - fixed #9342: Thingy - Cannot edit a thing 7.6.7 - fixed #9263: Thingy possibleValues processing, and List type autodetection. diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index e17c4eb32..2d1b7046a 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -19,6 +19,7 @@ use WebGUI::Text; use WebGUI::Form::File; use WebGUI::DateTime; use base 'WebGUI::Asset::Wobject'; +use Data::Dumper; #------------------------------------------------------------------- @@ -840,9 +841,10 @@ sub getFormElement { my $self = shift; my $data = shift; my %param; - my $db = $self->session->db; + my $session = $self->session; + my $db = $session->db; my $dbh = $db->dbh; - my $i18n = WebGUI::International->new($self->session,"Asset_Thingy"); + my $i18n = WebGUI::International->new($session,"Asset_Thingy"); $param{name} = "field_".$data->{fieldId}; my $name = $param{name}; @@ -865,7 +867,7 @@ sub getFormElement { if (WebGUI::Utility::isIn($data->{fieldType},qw(SelectList CheckList SelectBox Attachments))) { my @defaultValues; if ($self->session->form->param($name)) { - @defaultValues = $self->session->form->selectList($name); + @defaultValues = $session->form->selectList($name); } else { foreach (split(/\n/x, $data->{value})) { @@ -881,7 +883,7 @@ sub getFormElement { if ($class->isa('WebGUI::Form::List')) { delete $param{size}; - my $values = WebGUI::Operation::Shared::secureEval($self->session,$data->{possibleValues}); + my $values = WebGUI::Operation::Shared::secureEval($session,$data->{possibleValues}); if (ref $values eq 'HASH') { $param{options} = $values; } @@ -909,6 +911,7 @@ sub getFormElement { my $otherThingId = $data->{fieldType}; $otherThingId =~ s/^otherThing_(.*)/$1/x; $param{fieldType} = "SelectList"; + $class = 'WebGUI::Form::'. $param{fieldType}; my $options = (); my $tableName = 'Thingy_'.$otherThingId; my ($otherThingTableExists) = $db->quickArray('show tables like ?',[$tableName]); @@ -932,7 +935,7 @@ sub getFormElement { $param{value} = $data->{value} || $data->{defaultValue}; } - my $formElement = eval { WebGUI::Pluggable::instanciate($class, "new", [$self->session, \%param ])}; + my $formElement = eval { WebGUI::Pluggable::instanciate($class, "new", [$session, \%param ])}; return $formElement->toHtml(); }