[% IF loop.first %]<a name="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
[% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
<li data-category_code="[% pa.type.category_code | html %]">
- <label for="[% form_id | html %]">[% pa.type.description | html %]: </label>
+ [% IF pa.type.mandatory && pa.type.opac_editable %]
+ <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label>
+ [% ELSE %]
+ <label for="[% form_id | html %]">[% pa.type.description | html %]: </label>
+ [% END %]
[% IF pa.type.opac_editable %]
<input type="hidden" name="patron_attribute_code" value="[% pa.type.code | html %]" />
[% IF ( pa.type.authorised_value_category ) %]
[% ELSE %]
<textarea rows="2" cols="30" id="[% form_id | html %]" name="patron_attribute_value">[% pa_value | html %]</textarea>
[% END %]
+ [% IF pa.type.mandatory %]
+ <span class="required">Required</span>
+ [% END %]
<a href="#" class="clear-attribute">Clear</a>
[% IF ( pa.type.repeatable ) %]
<a href="#" class="clone-attribute">New</a>
%borrower = DelEmptyFields(%borrower);
- my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
+ my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
my $invalidformfields = CheckForInvalidFields(\%borrower);
delete $borrower{'password2'};
my $cardnumber_error_code;
$borrower{borrowernumber} = $borrowernumber;
my @empty_mandatory_fields =
- CheckMandatoryFields( \%borrower, $action );
+ ( CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
my $invalidformfields = CheckForInvalidFields(\%borrower);
# Send back the data to the template
return @empty_mandatory_fields;
}
+sub CheckMandatoryAttributes{
+ my ( $borrower, $attributes ) = @_;
+
+ my @empty_mandatory_fields;
+
+ for my $attribute (@$attributes ) {
+ my $attr = Koha::Patron::Attribute::Types->find($attribute->{code});
+ push @empty_mandatory_fields, $attribute->{code}
+ if $attr && $attr->mandatory && $attribute->{attribute} =~ m|^\s*$|;
+ }
+
+ return @empty_mandatory_fields;
+}
+
sub CheckForInvalidFields {
my $borrower = shift;
my @invalidFields;
}
foreach my $code ( keys %{$delete_candidates} ) {
- if ( Koha::Patron::Attributes->search({
+ if ( not $borrowernumber # self-registration
+ || Koha::Patron::Attributes->search({
borrowernumber => $borrowernumber, code => $code })->count > 0 )
{
push @attributes, { code => $code, attribute => '' }