Pflichtenhefte: CVars bei erfolglosem Speichern beibehalten
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 17 Feb 2015 12:13:43 +0000 (13:13 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 5 Mar 2015 12:42:58 +0000 (13:42 +0100)
SL/Controller/RequirementSpec.pm

index bd37a02..e249196 100644 (file)
@@ -375,6 +375,13 @@ sub create_or_update {
   my $params = delete($::form->{requirement_spec}) || { };
   my $cvars  = delete($::form->{cvars})            || { };
 
+  # Forcefully make it clear to Rose which custom_variables exist (or don't), so that the ones added with »add_custom_variables« are visible when calling »custom_variables«.
+  if ($is_new) {
+    $params->{custom_variables} = [];
+  } else {
+    $self->requirement_spec->custom_variables;
+  }
+
   $self->requirement_spec->assign_attributes(%{ $params });
 
   foreach my $var (@{ $self->requirement_spec->cvars_by_config }) {