diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index 0e0cd7cf7..4f98cacf0 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -8,6 +8,7 @@
7.5.22
- fixed: Layout template now gets prepared correctly
- fixed: When user does not have permissions to search/edit a thing a proper error is shown.
+ - fixed: Thingy now requires at least 1 field for a new Thing.
7.5.21
- fixed: purchase detail screen shows incorrectly in Safari
diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm
index 032dbb8dd..a55a85443 100644
--- a/lib/WebGUI/Asset/Wobject/Thingy.pm
+++ b/lib/WebGUI/Asset/Wobject/Thingy.pm
@@ -1185,6 +1185,7 @@ before the form is submitted.
sub www_editThing {
my $self = shift;
+ my $warning = shift;
my $session = $self->session;
my ($tabForm, $output, %properties, $tab, %afterSave, %defaultView, $fields);
my ($fieldsHTML, $fieldsViewScreen, $fieldsSearchScreen);
@@ -1563,8 +1564,9 @@ sub www_editThing {
-value => $properties{thingsPerPage},
);
$tab->raw($fieldsSearchScreen);
-
- $output = $tabForm->print;
+ #if($warning){$output .= "";}
+ if($warning){$output .= "$warning";}
+ $output .= $tabForm->print;
my $dialog = "
\n"
."
".$i18n->get('add field label')."
\n"
@@ -1599,6 +1601,10 @@ sub www_editThingSave {
my $form = $self->session->form;
my ($thingId, $fields);
$thingId = $self->session->form->process("thingId");
+
+ $fields = $self->session->db->read('select * from Thingy_fields where assetId = '.$self->session->db->quote($self->get("assetId")).' and thingId = '.$self->session->db->quote($thingId).' order by sequenceNumber');
+
+
$self->setCollateral("Thingy_things","thingId",{
thingId=>$thingId,
label=>$form->process("label"),
@@ -1625,7 +1631,12 @@ sub www_editThingSave {
sortBy=>$form->process("sortBy"),
},0,1);
- $fields = $self->session->db->read('select * from Thingy_fields where assetId = '.$self->session->db->quote($self->get("assetId")).' and thingId = '.$self->session->db->quote($thingId).' order by sequenceNumber');
+ if($fields->rows < 1){
+ $self->session->log->warn("Thing failed to create because it had no fields");
+ my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
+ return $self->www_editThing($i18n->get("thing must have fields"));
+ }
+
while (my $field = $fields->hashRef) {
my $display = $self->session->form->process("display_".$field->{fieldId}) || 0;
my $viewScreenTitle = $self->session->form->process("viewScreenTitle_".$field->{fieldId}) || 0;
diff --git a/lib/WebGUI/i18n/English/Asset_Thingy.pm b/lib/WebGUI/i18n/English/Asset_Thingy.pm
index d6a57c52b..c79de17f0 100644
--- a/lib/WebGUI/i18n/English/Asset_Thingy.pm
+++ b/lib/WebGUI/i18n/English/Asset_Thingy.pm
@@ -934,8 +934,12 @@ search has been done.|,
'no permission to search' => {
message => q|You do not have permissions to search this Thing.|,
lastUpdated => 1219424285,
- }
-
+ },
+
+ 'thing must have fields' => {
+ message => q|Error: You must assign fields to your new Thing.|,
+ lastUpdated => 1219424285,
+ },
};
1;