From 1e19ad0aeef02769569fa478f0de26106771b3cc Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 7 Jan 2015 17:32:06 +1100 Subject: [PATCH] Bug 13526 - Mandatory fields should not be able to be hidden in borrower self-registration Currently, mandatory fields in the borrower self-registration can be hidden. This causes problems since the validator rejects the registration, even though all required fields on the screen have been filled out. This is especially a problem when using the system preference "PatronSelfRegistrationVerifyByEmail", since it automatically makes "email" a mandatory field. This patch makes it so that a mandatory field cannot be hidden on the self-registration page. _TEST PLAN_ Before applying 1) Hide the "email" and the "emailpro" fields using the "PatronSelfRegistrationBorrowerUnwantedField" system preference. 2) Make the "email" and the "emailpro" fields mandatory using the "PatronSelfRegistrationBorrowerMandatoryField" system preference. 3) Note that you cannot see "Primary email" or "Secondary email" on the self registration page. (The registration page which can be found by turning on "PatronSelfRegistration" and filling in "PatronSelfRegistrationDefaultCategory". The link will be on opac-main.pl on the right side of the screen under the login box.) 4) Note that you cannot submit a self-registration request as the system tells you that you have not filled in all the mandatory fields. 5) Apply the patch && refresh the self registration page 6) Note that you can now see "Primary email" and "Secondary email" on the self-registration screen". --- opac/opac-memberentry.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 6abe803..fb407d6 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -56,10 +56,13 @@ if ( $action eq q{} ) { } } +my $mandatory = GetMandatoryFields($action); +my $hidden = GetHiddenFields($mandatory); + $template->param( action => $action, - hidden => GetHiddenFields(), - mandatory => GetMandatoryFields($action), + hidden => $hidden, + mandatory => $mandatory, member_titles => GetTitles() || undef, branches => GetBranchesLoop(), OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), @@ -229,6 +232,7 @@ $template->param( output_html_with_http_headers $cgi, $cookie, $template->output; sub GetHiddenFields { + my ($mandatory) = @_; my %hidden_fields; my $BorrowerUnwantedField = @@ -237,6 +241,8 @@ sub GetHiddenFields { my @fields = split( /\|/, $BorrowerUnwantedField ); foreach (@fields) { next unless m/\w/o; + #Don't hide mandatory fields + next if $mandatory->{$_}; $hidden_fields{$_} = 1; } -- 1.8.1.4