rblank  committed 97f2e86

0.12.2dev: In preference panels, only wrap a panel in a `<form>` and add a "Save changes" button if the panel doesn't contain any forms itself. This allows using more than one form e.g. in the "Advanced" panel, and fixes an issue where pressing ENTER in the "Session key" edit box would trigger restoring a session instead of changing the session ID.

Part of #9658.

  • Participants
  • Parent commits f954b84
  • Branches 0.12-stable

Comments (0)

Files changed (3)

File trac/prefs/templates/prefs.html

     ${select("*[local-name() != 'title']")}
-  <py:match path="body" once="true" buffer="false"><body>
+  <py:match path="body" once="true" buffer="true"><body>
     <div id="content" class="prefs">
       <p>This page lets you customize your personal settings for this site.
           <a py:strip="name == active_panel" href="${href.prefs(name)}">${label}</a>
-      <div id="tabcontent">
-        <form id="userprefs" action="" method="post">
+      <div id="tabcontent" py:with="has_forms = list(select('.//form'))">
+        <form id="userprefs" action="" method="post" py:strip="has_forms">
-          <div class="buttons">
+          <div class="buttons" py:if="not has_forms">
             <input type="hidden" name="action" value="save" />
             <input type="submit" value="${_('Save changes')}" />
           </div >

File trac/prefs/templates/prefs_advanced.html

-    <div class="field">
+    <div class="field"><form action="" method="post">
       <label>Session key:
-        <input type="text" name="newsid" size="30"
-               value="${settings.session_id}" />
+        <input type="text" name="newsid" size="30" value="${settings.session_id}" />
+      <input type="submit" name="change" value="${_('Change')}" />
       <p class="hint">The session key is used to identify stored custom
       settings and session data on the server. Although it is
       automatically generated by default, you may change it to something
       easier to remember at any time if you wish to load your settings
       in a different web browser.</p>
-    </div>
+    </form></div>
-    <div class="field">
+    <div class="field"><form action="" method="post">
       <label>Restore session:
         <input type="text" name="loadsid" size="30" value="" />
       <p class="hint">You may load a previously created session by entering the
       corresponding session key below. This lets you share settings between
       multiple computers and web browsers.</p>
-    </div>
+    </form></div>

File trac/prefs/

     def _do_load(self, req):
         if req.authname == 'anonymous':
             oldsid = req.args.get('loadsid')
-            req.session.get_session(oldsid)
+            if oldsid:
+                req.session.get_session(oldsid)
+                add_notice(req, _('The session has been loaded.'))