[Koha-patches] [PATCH] Bug 11805 - Use validation plugin when creating new basket in Acquisitions

Owen Leonard oleonard at myacpl.org
Thu Feb 20 21:45:34 CET 2014


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.
---
 .../prog/en/modules/acqui/basketheader.tt          |   27 +++-----------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt
index 85fc946..84b318c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt
@@ -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>  
-                        <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>
-- 
1.7.9.5


More information about the Koha-patches mailing list