From 0c63642f1dae39333071948512b4519fe7020d30 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 25 Sep 2024 21:17:22 +0000 Subject: [PATCH] Bug 38005: Pass opac_editable to search params when interface is OPAC 1. Create a patron attribute. 2. Check it as Mandatory. 3. Do NOT make it display or editable in the OPAC. 4. Go to OPAC self reg form 5. You will not see the attribute. 6. Submit the form and see the 500 error. 7. Apply patch, restart_all. 8. Try again, now you should be able to submit the OPAC form. Signed-off-by: Roman Dolny Signed-off-by: David Nind --- Koha/Patron.pm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index fcbd6cd71e..cf359d4b3b 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2182,17 +2182,22 @@ sub extended_attributes { } # Check globally mandatory types - my @required_attribute_types = - Koha::Patron::Attribute::Types->search( - { - mandatory => 1, - category_code => [ undef, $self->categorycode ], - 'borrower_attribute_types_branches.b_branchcode' => - undef, - }, - { join => 'borrower_attribute_types_branches' } - )->get_column('code'); - for my $type ( @required_attribute_types ) { + my $interface = C4::Context->interface; + my $params = { + mandatory => 1, + category_code => [ undef, $self->categorycode ], + 'borrower_attribute_types_branches.b_branchcode' => undef, + }; + + if ( $interface eq 'opac' ) { + $params->{opac_editable} = 1; + } + + my @required_attribute_types = Koha::Patron::Attribute::Types->search( + $params, + { join => 'borrower_attribute_types_branches' } + )->get_column('code'); + for my $type (@required_attribute_types) { Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw( type => $type, ) if !$new_types->{$type}; -- 2.39.5