@@ -, +, @@ on the suggestion form in OPAC --- .../bootstrap/en/modules/opac-suggestions.tt | 41 +++++++++----------- opac/opac-suggestions.pl | 8 ++++ 2 files changed, 26 insertions(+), 23 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -35,14 +35,14 @@

Enter a new purchase suggestion

Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion

-

Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.

+

Only certain fields (marked in red) are required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.

-
+
    -
  1. +
  2. -
  3. +
  4. @@ -89,7 +89,7 @@
    - Cancel + Cancel
    [% END %] @@ -337,25 +337,20 @@ return true; }); [% END %] - }); - - function Check(f) { - var _alertString=""; - var alertString2; - - if(f.title.value.length ==0){ - _alertString += _("- You must enter a Title") + "\n"; - } - - if (_alertString.length==0) { - f.submit(); - } else { - alertString2 = _("Form not submitted because of the following problem(s)"); - alertString2 += "\n------------------------------------------------------------------------------------\n\n"; - alertString2 += _alertString; - alert(alertString2); + [% IF ( op_add && mandatoryfields ) %] + { + var FldsRequired = [[% mandatoryfields %]]; + for (var i = 0; i < FldsRequired.length; i++) { + var rq_input = $('#' + FldsRequired[i]); + if (rq_input.length != 1) continue; + $(rq_input).attr("required", "required"); + var rq_label = $("label[for=" + rq_input.attr("id") + "]"); + if (rq_label.length != 1) continue; + $(rq_label).addClass('required'); + } } - } + [% END %] + }); //]]> [% END %] --- a/opac/opac-suggestions.pl +++ a/opac/opac-suggestions.pl @@ -207,6 +207,13 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { $template->param( branchloop => $branchloop ); } +my $mandatoryfields = ''; +{ + last unless ($op eq 'add'); + my $fldsreq_sp = C4::Context->preference("OPACSuggestionMandatoryFields") || 'title'; + $mandatoryfields = join(', ', (map { '"'.$_.'"'; } sort split(/\s*\,\s*/, $fldsreq_sp))); +} + $template->param( %$suggestion, suggestions_loop => $suggestions_loop, @@ -216,6 +223,7 @@ $template->param( messages => \@messages, suggestionsview => 1, suggested_by_anyone => $suggested_by_anyone, + mandatoryfields => $mandatoryfields, patrons_pending_suggestions_count => $patrons_pending_suggestions_count, ); --