Bug 11805 - Use validation plugin when creating new basket in Acquisitions
authorOwen Leonard <oleonard@myacpl.org>
Thu, 20 Feb 2014 20:42:37 +0000 (15:42 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 27 Feb 2014 15:44:48 +0000 (15:44 +0000)
The page for adding a new basket in Acquisitions includes some custom
form validation JavaScript which can be removed in favor of HTML5
validation attributes and Koha's built-in validation plugin. This patch
does so.

To test, apply the patch and go to Acquisitions -> Choose a vendor ->
New basket. Try submitting the form without entering a basket name. This
should trigger a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing basket should also work correctly.

Patch works as expected.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as expected, passes all tests and QA script.
Tried adding a new basket with/without basket name and editing
an existing basket editing/emptying the basket name.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt

index 85fc946..84b318c 100644 (file)
@@ -8,26 +8,6 @@
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-// to check if the data are correctly entered.
-function Check(ff) {
-    var ok=0;
-    var _alertString="Form not submitted because of the following problem(s)";
-    _alertString +="\n-------------------------------------------------------------------\n\n";
-    if (!(isNotNull(ff.basketname,0))){
-        ok=1;
-        _alertString += "- name missing\n";
-    }
-    if (ok) { // if there is a problem
-        alert(_alertString);
-    return false;
-}
-// if all is good
-    ff.submit();
-}
-//]]>
-</script>
 </head>
 <body id="acq_basketheader" class="acq">
 [% INCLUDE 'header.inc' %]
@@ -54,7 +34,7 @@ function Check(ff) {
             <h1>Edit basket [% basketname %]</h1>
         [% ELSE %]<h1>Add a basket to [% booksellername %]</h1>
         [% END %]
-    <form name="Aform" action="[% script_name %]" method="post">
+    <form name="Aform" action="[% script_name %]" method="post" class="validated">
         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
         <fieldset class="rows">
             <ol>
@@ -66,7 +46,8 @@ function Check(ff) {
                 [% END %]
                 <li>
                     <label for="basketname" class="required">Basket name: </label> &nbsp;
-                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname %]" class="focus" />
+                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname %]" required="required" class="required" />
+                        <span class="required">Required</span>
                 </li>
                  <li>
                     <label for="billingplace">Billing place:</label>
@@ -136,7 +117,7 @@ function Check(ff) {
         </fieldset>
         <fieldset class="action">
             <input type="hidden" name="op" value="add_validate" />
-            <input type="button" value="Save" onclick="Check(this.form);" />
+            <input type="submit" value="Save" />
             <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">Cancel</a>
         </fieldset>
     </form>