[Koha-patches] [PATCH] Bug 11769 - Use validation plugin when creating new MARC framework

Owen Leonard oleonard at myacpl.org
Fri Feb 14 21:20:47 CET 2014


The page for adding a new MARC framework 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 Administration -> MARC bibliographic
framework -> New framework. Try submitting the form without entering a
tag number. This should trigger a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing framework should also work correctly.
---
 .../prog/en/modules/admin/biblio_framework.tt      |   40 ++------------------
 1 file changed, 3 insertions(+), 37 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt
index ec458b3..4ef8103 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt
@@ -8,40 +8,6 @@
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript">
-//<![CDATA[
-
-function isNotNull(f,noalert) {
-    if (f.value.length ==0) {
-        return false;
-    }
-    return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-function Check(f) {
-    var ok=1;
-    var _alertString="";
-    var alertString2;
-    if (f.frameworkcode.value.length==0) {
-        _alertString += "\n- " + _("Framework code missing");
-    }
-    if (!(isNotNull(window.document.Aform.frameworktext))) {
-        _alertString += "\n- " + _("Description missing");
-    }
-    if (_alertString.length==0) {
-        document.Aform.submit();
-    } else {
-        alertString2  = _("Form not submitted because of the following problem(s)");
-        alertString2 += "\n------------------------------------------------------------------------------------\n";
-        alertString2 += _alertString;
-        alert(alertString2);
-        return false;
-    }
-    return true;
-}
-
-//]]>
-</script>
-<script type="text/javascript">
 /* Import/Export from/to spreadsheet */
 
     var importing = false;
@@ -141,7 +107,7 @@ function Check(f) {
 
 [% IF ( add_form ) %]
     <h1>[% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]</h1>
-    <form action="[% script_name %]" name="Aform" method="post" onsubmit="return Check(this);">
+    <form action="[% script_name %]" name="Aform" method="post" class="validated">
         <input type="hidden" name="op" value="add_validate" />
     <fieldset class="rows">
     <ol>
@@ -150,10 +116,10 @@ function Check(f) {
             <input type="hidden" name="modif" value="1" />
         </li>
 	[% ELSE %]
-        <li><label for="frameworkcode">Framework code: </label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" /></li>
+        <li><label for="frameworkcode">Framework code: </label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" required="required" class="required" /></li>
 	[% END %]
         <li><label for="description">Description: </label>
-        <input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" /></li></ol></fieldset>
+        <input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" required="required" class="required" /></li></ol></fieldset>
         <fieldset class="action">	<input type="submit" value="Submit" class="submit" /></fieldset>
     </form>
 [% END %]
-- 
1.7.9.5


More information about the Koha-patches mailing list