@@ -, +, @@ - Set 1+ patron's attribute(s) mandatory - Use the self-registration feature and confirm that you cannot selfreg - Same with the modification form (logged in) --- .../bootstrap/en/modules/opac-memberentry.tt | 9 +++++++- opac/opac-memberentry.pl | 21 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -907,7 +907,11 @@ [% IF loop.first %][% END %] [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
  • - + [% IF pa.type.mandatory && pa.type.opac_editable %] + + [% ELSE %] + + [% END %] [% IF pa.type.opac_editable %] [% IF ( pa.type.authorised_value_category ) %] @@ -928,6 +932,9 @@ [% ELSE %] [% END %] + [% IF pa.type.mandatory %] + Required + [% END %] Clear [% IF ( pa.type.repeatable ) %] New --- a/opac/opac-memberentry.pl +++ a/opac/opac-memberentry.pl @@ -123,7 +123,7 @@ if ( $action eq 'create' ) { %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; @@ -259,7 +259,7 @@ elsif ( $action eq 'update' ) { $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 @@ -412,6 +412,20 @@ sub CheckMandatoryFields { 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; @@ -689,7 +703,8 @@ sub ParsePatronAttributes { } 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 => '' } --