Bug 27618: Don't show dropdown if PatronSelfRegistrationLibraryList only has one library

This patch modifies the patron entry form in the OPAC so that if there
is only one library to choose from, the input is hidden and the single
library displays as text.

To test, apply the patch and enable PatronSelfRegistration.

- Modify the PatronSelfRegistrationLibraryList system preference to
  include only one library.
- Go to the self-registratoin page in the OPAC.
- Under "Home library," you should see the library name. If you inspect
  the source you should see the library branchcode in a hidden form.
- Confirm that the form submission includes the correct library
  information.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2021-02-04 12:20:27 +00:00 committed by Jonathan Druart
parent 66bd88a6e6
commit fecb9a11fc
1 changed files with 22 additions and 14 deletions

View File

@ -239,21 +239,29 @@
[% UNLESS hidden.defined('branchcode') %]
<li>
[% IF mandatory.defined('branchcode') %]
<label for="borrower_branchcode" class="required">Home library:</label>
[% ELSE %]
<label for="borrower_branchcode">Home library:</label>
[% END %]
<select id="borrower_branchcode" name="borrower_branchcode">
[% FOREACH l IN libraries %]
[% IF l.branchcode == borrower.branchcode %]
<option value="[% l.branchcode | html %]" selected="selected">[% l.branchname | html %]</option>
[% ELSE %]
<option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
[% END %]
[% IF ( libraries.size > 1 ) %]
[% IF mandatory.defined('branchcode') %]
<label for="borrower_branchcode" class="required">Home library:</label>
[% ELSE %]
<label for="borrower_branchcode">Home library:</label>
[% END %]
</select>
<select id="borrower_branchcode" name="borrower_branchcode">
[% FOREACH l IN libraries %]
[% IF l.branchcode == borrower.branchcode %]
<option value="[% l.branchcode | html %]" selected="selected">[% l.branchname | html %]</option>
[% ELSE %]
<option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
[% END %]
[% END %]
</select>
[% ELSE %]
<span class="label">Home library:</span>
[% FOREACH l IN libraries %]
[% l.branchname | html %]
<input type="hidden" name="borrower_branchcode" value="[% l.branchcode | html %]" />
[% END %]
[% END %]
</li>
[% END %]