Add label id targets back to input labels
authorKarl O. Pinc <kop@karlpinc.com>
Sat, 3 Aug 2024 20:43:25 +0000 (15:43 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sat, 3 Aug 2024 20:43:25 +0000 (15:43 -0500)
As it turns out, you can't use "for" as an argument/tag element attribute
with mako.  At least not when inheriting the namespace into templates
at arbitrary depth.

src/pgwui_common/templates/auth_base.mak
src/pgwui_common/templates/db_base.mak
src/pgwui_common/templates/lib.mak

index c017d3141ad296d0059c31b59e103bab7385ac1c..eb92dbc3d1ab350bcf2063a4c09364929c1b3c90 100644 (file)
@@ -97,7 +97,7 @@
 
 <%def name="user_row(tab_index, havecreds, user)">
       <tr>
-        <%self.lib:td_label>Username</%self.lib:td_label>
+        <%self.lib:td_label for_id="user_id">Username</%self.lib:td_label>
           % if havecreds:
             <td><span id="user_id">${user}</span></td>
           % else:
 <%def name="password_row(tab_index, havecreds)">
       % if not havecreds:
         <tr>
-          <%self.lib:td_label>Password</%self.lib:td_label>
+          <%self.lib:td_label for_id="password_id">Password</%self.lib:td_label>
           <%self.lib:td_input tab_index="${tab_index}">
             <input name="password"
                    tabindex="${tab_index.val}"
index 5bd818deb67109d308d56e278afcb7e0627766b9..ec7a99ed0242d62ed7ffbba356cda90f8d3da03e 100644 (file)
@@ -66,7 +66,7 @@
 
 <%def name="database_row(tab_index)">
   <tr>
-    <%self.lib:td_label>Database</%self.lib:td_label>
+    <%self.lib:td_label for_id="db_id">Database</%self.lib:td_label>
     <%self.lib:td_input tab_index="${tab_index}">
       <input name="db"
              tabindex="${tab_index.val}"
index 398a311e0c453b88705fc6f03a756571a3ae8b62..97e2dbf191de5efe60a585ec1e4f405e9c6aa8e3 100644 (file)
 
 ## Table data
 
-<%def name="td_label()">
+<%def name="td_label(for_id=None)">
         <td class="label">
-          <label for="user_id">${capture(caller.body) | trim}:</label>
+          <%
+            for_attr = ''
+            if for_id is not None:
+              for_attr = f'for="{for_id}"'
+          %>
+          <label ${for_attr}>${capture(caller.body) | trim}:</label>
         </td>
 </%def>