diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index c75ed692b..2e56ad161 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -2308,6 +2308,15 @@ sub www_getThingViaAjax { return $session->privilege->insufficient() unless $self->canViewThing($thingId, $thingProperties->{groupIdView}); + my @field_loop; + my $fields = $session->db->read('select * from Thingy_fields where assetId=? and thingId=? order by sequenceNumber' + ,[$self->getId,$thingId]); + while (my $field = $fields->hashRef) { + $field->{formElement} = $self->getFormElement($field); + push(@field_loop,$field); + } + $thingProperties->{field_loop} = \@field_loop; + $session->http->setMimeType("application/json"); return JSON->new->utf8->encode($thingProperties); } diff --git a/t/Asset/Wobject/Thingy.t b/t/Asset/Wobject/Thingy.t index 89c712dcd..0b594d551 100644 --- a/t/Asset/Wobject/Thingy.t +++ b/t/Asset/Wobject/Thingy.t @@ -116,6 +116,7 @@ cmp_deeply( onEditWorkflowId=>undef, onDeleteWorkflowId=>undef, sortBy=>undef, + field_loop=>[], }, 'Getting newly added thing as JSON: www_getThingViaAjax returns correct data as JSON.' );