Koha/koha-tmpl/opac-tmpl/bootstrap/en/includes/av-build-dropbox.inc
Nick Clemens cb95c91403 Bug 27297: Add required and blank options to av-build-dropbox.inc
This patch adds two options to av-build-drobx
required - which will add the required attribute to the select
blank - which will add a blank option to avoid preselecting others

To test:
1 - In OpacSuggestionMandatoryFeilds select itemtype
2 - Go to OPAC
3 - Add a suggestion
4 - Don't fill out any fields
5 - Submit
6 - Suggestion is added
7 - Delete it
8 - Apply patch
9 - Add a suggestion
10 - Note itemtyp edefaults to 'None'
11 - You cannot submit until you select a value

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-01-19 16:03:34 +01:00

31 lines
1.2 KiB
HTML

[% USE AuthorisedValues %]
[%# Parameters: %]
[%# name: the name of the select element %]
[%# category: the authorised value category %]
[%# default: the default authorised value to select %]
[%# class: the CSS class of the select element %]
[%# size: the size to use for the input (generated if the authorised value category does not exist). %]
[% SET avs = AuthorisedValues.GetAuthValueDropbox( category ) %]
[% DEFAULT class = '' size = 20 %]
[% IF avs %]
[% IF required %]
<select id="[% name | html %]" name="[% name | html %]" class="[% class | html %]" required="required">
[% ELSE %]
<select id="[% name | html %]" name="[% name | html %]" class="[% class | html %]">
[% END %]
[% IF blank %]
<option value="">None</option>
[% END %]
[% FOR av IN avs %]
[% IF av.authorised_value == default %]
<option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html_entity %]</option>
[% ELSE %]
<option value="[% av.authorised_value | html %]">[% av.lib | html_entity %]</option>
[% END %]
[% END %]
</select>
[% ELSE %]
<input type="text" id="[% name | html %]" name="[% name | html %]" size="[% size | html %]" value="[% default | html_entity %]" class="[% class | html %]" />
[% END %]