Bug 11805 - Use validation plugin when creating new basket in Acquisitions

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>
This commit is contained in:
Owen Leonard 2014-02-20 15:42:37 -05:00 committed by Galen Charlton
parent a4a014e365
commit cd089028b8

View 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>