[Grok-dev] Server Control - Admin message - functional change
Michael Haubenwallner
michael at d2m.at
Sat Feb 9 09:22:31 EST 2008
There is a small problem with grok/admin/view_templates/server.pt
When you enter some text into the input field under "Manage server
process" or "Admin message" and hit RETURN instead of clicking the
[Save] button, the form is submitted - but it is not sure, which one of
the three button actions is executed.
In fact i accidently stopped my instance a few times until i found the
reason.
This is a common problem with multiple submit buttons.
There are 2 solutions: create three distinct forms to handle each of the
action groups or add some Javascript to disable return keys inside the
input fields.
I've choosen the second option, attaching a patch for the file.
Michael
--
http://www.zope.org/Members/d2m
http:/planetzope.org
-------------- next part --------------
Index: admin/view_templates/server.pt
===================================================================
--- admin/view_templates/server.pt (revision 83676)
+++ admin/view_templates/server.pt (working copy)
@@ -1,5 +1,17 @@
<html metal:use-macro="context/@@grokadminmacros/macros/gaia-page">
<div metal:fill-slot="content">
+ <script language="JavaScript">
+ function disableEnterKey(e)
+ {
+ var key;
+ if(window.event)
+ key = window.event.keyCode; //IE
+ else
+ key = e.which; //firefox
+ return (key != 13);
+ }
+ </script>
+
<h1>Manage your Zope 3 instance</h1>
<form method="post" action=""
@@ -9,7 +21,8 @@
<legend>Manage server process</legend>
<input type="submit" name="restart" class="button" value="Restart Zope 3" />
<input type="submit" name="shutdown" class="button" value="Stop Zope 3" />
- after <input type="text" name="time" value="0" size="4" /> seconds
+ after <input type="text" name="time" value="0" size="4"
+ onKeyPress="return disableEnterKey(event)" /> seconds
</p>
</fieldset>
@@ -21,6 +34,7 @@
<input
type="text"
name="admin_message"
+ onKeyPress="return disableEnterKey(event)"
tal:attributes="value view/current_message/message|nothing"
/>
More information about the Grok-dev
mailing list