From 0c49e9616e8e6c7d50bf099ac80097d884872fa9 Mon Sep 17 00:00:00 2001
From: Bruce Toll <btoll@dhsus.com>
Date: Mon, 17 Oct 2016 20:19:56 -0400
Subject: [PATCH] Minor improvements to Integration Example part 2v2

Updated the userForm-template to in the widgetgallery Integration
Example to use a macro block to reduce duplicated XML and, hopefully,
make the example easier to read.

Updated supporting documentation in the widgetgallery. Also, removed an
unused bindSTring for "userForm-template" in FormWidgets::introduction.

NOTE: contains fix for label for.
---
 examples/widgetgallery/FormWidgets.C    |   4 +-
 examples/widgetgallery/approot/text.xml | 107 ++++++--------------------------
 2 files changed, 21 insertions(+), 90 deletions(-)

diff --git a/examples/widgetgallery/FormWidgets.C b/examples/widgetgallery/FormWidgets.C
index 9c83a65..c2bac8d 100644
--- a/examples/widgetgallery/FormWidgets.C
+++ b/examples/widgetgallery/FormWidgets.C
@@ -75,8 +75,6 @@ Wt::WWidget *FormWidgets::introduction()
                      reindent(tr("simpleForm-template")), Wt::PlainText);
   result->bindString("form-field",
                      reindent(tr("form-field")), Wt::PlainText);
-  result->bindString("userForm-template",
-                     reindent(tr("userForm-template")), Wt::PlainText);
 
   return result;
 }
@@ -310,5 +308,7 @@ Wt::WWidget *FormWidgets::example()
                      reindent(tr("form-field")), Wt::PlainText);
   result->bindString("userForm-template",
                      reindent(tr("userForm-template")), Wt::PlainText);
+  result->bindString("userForm-field",
+                     reindent(tr("userForm-field")), Wt::PlainText);
   return result;
 }
diff --git a/examples/widgetgallery/approot/text.xml b/examples/widgetgallery/approot/text.xml
index 9a10946..afb344d 100644
--- a/examples/widgetgallery/approot/text.xml
+++ b/examples/widgetgallery/approot/text.xml
@@ -1150,101 +1150,24 @@
     </div>
   </message>
 
-  <message id="form-field">
+  <message id="userForm-field">
     <div class="form-group">
-      <label class="control-label col-sm-2" for="${id:{2}}"> ${1} </label>
-      <div class="col-sm-5"> ${2} </div>
-      <div class="help-block col-sm-5"> ${3} </div>
+      <label class="control-label col-sm-2" for="${id:{2}}"> {1} </label>
+      <div class="col-sm-5"> ${{2}} </div>
+      <div class="help-block col-sm-5"> ${{2}-info} </div>
     </div>
   </message>
 
   <message id="userForm-template">
     <legend>${title}</legend>
     <div class="form-horizontal">
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          First name
-        </label>
-        <div class="col-sm-5">
-          ${first-name}
-        </div>
-        <div class="help-block col-sm-5">
-          ${first-name-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          Last name
-        </label>
-        <div class="col-sm-5">
-          ${last-name}
-        </div>
-        <div class="help-block col-sm-5">
-          ${last-name-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          Country
-        </label>
-        <div class="col-sm-5">
-          ${country}
-        </div>
-        <div class="help-block col-sm-5">
-          ${country-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          City
-        </label>
-        <div class="col-sm-5">
-          ${city}
-        </div>
-        <div class="help-block col-sm-5">
-          ${city-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          Birth date
-        </label>
-        <div class="col-sm-5">
-          ${birth}
-        </div>
-        <div class="help-block col-sm-5">
-          ${birth-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          Children
-        </label>
-        <div class="col-sm-5">
-          ${children}
-        </div>
-        <div class="help-block col-sm-5">
-          ${children-info}
-        </div>
-      </div>
-
-      <div class="form-group">
-        <label class="control-label col-sm-2"  for="${id:first-name}">
-          Remarks
-        </label>
-        <div class="col-sm-5">
-          ${remarks}
-        </div>
-        <div class="help-block col-sm-5">
-          ${remarks-info}
-        </div>
-      </div>
-
+      ${block:userForm-field "First name" first-name}
+      ${block:userForm-field "Last name" last-name}
+      ${block:userForm-field "Country" country}
+      ${block:userForm-field "City" city}
+      ${block:userForm-field "Birth date" birth}
+      ${block:userForm-field "Children" children}
+      ${block:userForm-field "Remarks" remarks}
       <div class="form-group">
         <div class="col-sm-offset-2 col-sm-10">
           ${submit-button} <span class="help-inline">${submit-info}</span>
@@ -2598,6 +2521,14 @@
         <pre>${userForm-template}</pre>
       </fieldset>
       <p>
+        To reduce code duplication, the above userForm-template places common
+        code in a macro block (with <tt>message id="userForm-field"</tt>).
+      </p>
+      <fieldset class="src">
+        <legend>source</legend>
+        <pre>${userForm-field}</pre>
+      </fieldset>
+      <p>
         Here is the implementation of <tt>WFormModel</tt> and <tt>
         WTemplateFormView</tt>.
       </p>
-- 
2.1.4

