[4/5] testbot/web: Use a PropertyDescriptor and FormPage::GenerateField() to handle the Remarks field.

Francois Gouget fgouget at codeweavers.com
Fri Jun 13 11:28:53 CDT 2014


This increases code reuse and avoids losing that field if some other field was invalid.
---

Without this patch if one types a remark but forgets to fill in the 
email address, the remark gets lost when the page reloads and displays 
the error message.

 testbot/web/Register.pl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/testbot/web/Register.pl b/testbot/web/Register.pl
index 1e18e23..70d8868 100644
--- a/testbot/web/Register.pl
+++ b/testbot/web/Register.pl
@@ -21,6 +21,8 @@ use strict;
 package RegisterPage;
 
 use URI::Escape;
+
+use ObjectModel::BasicPropertyDescriptor;
 use ObjectModel::CGI::ItemPage;
 use WineTestBot::Config;
 use WineTestBot::Users;
@@ -33,6 +35,11 @@ sub _initialize($$$)
   my ($self, $Request, $RequiredRole) = @_;
 
   $self->SUPER::_initialize($Request, $RequiredRole, CreateUsers());
+
+  $self->GetParam("Remarks", "") if (!defined $self->GetParam("Remarks"));
+  $self->{ExtraProperties} = [
+    CreateBasicPropertyDescriptor("Remarks", "Remarks", !1, !1, "textarea", 200)
+  ];
 }
 
 sub GetTitle($)
@@ -81,8 +88,10 @@ sub GenerateFields($)
   my ($self) = @_;
 
   print "<div><input type='hidden' name='Status' value='active'></div>\n";
+
   $self->SUPER::GenerateFields();
-  print "<div class='DetailProperty'><label>Remarks</label><textarea name='Remarks' cols='40' rows='4'></textarea></div>\n";
+  map { $self->GenerateField($_, "rw") } @{$self->{ExtraProperties}};
+
   $self->GenerateRequiredLegend();
   $self->{HasRequired} = !1;
 }
-- 
2.0.0




More information about the wine-patches mailing list