From ee55a7bd79bb7761c21a385713e3457b2efcaa80 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. --- Koha/Patron.pm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index fcbd6cd71ed..cf359d4b3be 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.2