@@ -, +, @@ of required fields - Log in to the OPAC and go to Your purchase suggestions -> New purchase suggestion. - Verify that the fields specified in OPACSuggestionMandatoryFields are highlighted and marked "required." - Verify that you can't submit the form without filling out these fields. --- .../bootstrap/en/modules/opac-suggestions.tt | 162 ++++++++++++++---- opac/opac-suggestions.pl | 11 +- 2 files changed, 134 insertions(+), 39 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -43,42 +43,145 @@
    -
  1. -
  2. +
  3. + [% IF ( title_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  4. +
  5. + [% IF ( author_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  6. - + [% IF ( copyrightdate_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  7. -
  8. -
  9. -
  10. -
  11. -
  12. -
  13. - [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] +
  14. + [% IF ( isbn_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  15. +
  16. + [% IF ( publishercode_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  17. +
  18. + [% IF ( collectiontitle_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  19. +
  20. + [% IF ( place_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  21. +
  22. + [% IF ( quantity_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  23. +
  24. + [% IF ( itemtype_required ) %] + + [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] + Required + [% ELSE %] + + [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] + [% END %]
  25. [% IF branchcode %] -
  26. - +
  27. + [% IF ( branchcode_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  28. [% END %] [% IF ( patron_reason_loop ) %]
  29. - - + [% IF ( patronreason_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  30. [% END %]
  31. - - + [% IF ( note_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  32. @@ -339,19 +442,6 @@ return true; }); [% END %] - [% IF ( op_add && mandatoryfields ) %] - { - var FldsRequired = [[% mandatoryfields | $raw %]]; - 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 %] }); //]]> --- a/opac/opac-suggestions.pl +++ a/opac/opac-suggestions.pl @@ -208,13 +208,19 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { $template->param( branchcode => $branchcode ); } -my $mandatoryfields = ''; +my @mandatoryfields; + { last unless ($op eq 'add'); my $fldsreq_sp = C4::Context->preference("OPACSuggestionMandatoryFields") || 'title'; - $mandatoryfields = join(', ', (map { '"'.$_.'"'; } sort split(/\s*\,\s*/, $fldsreq_sp))); + @mandatoryfields = split( ",", $fldsreq_sp ); + foreach (@mandatoryfields) { + $template->param( $_."_required" => 1); + } } + + $template->param( %$suggestion, suggestions_loop => $suggestions_loop, @@ -224,7 +230,6 @@ $template->param( messages => \@messages, suggestionsview => 1, suggested_by_anyone => $suggested_by_anyone, - mandatoryfields => $mandatoryfields, patrons_pending_suggestions_count => $patrons_pending_suggestions_count, ); --