=back
+=item ignore_invisible_subfields
+
+Skip the subfields that are not visible on the editor.
+
+When duplicating an item we do not want to retrieve the subfields that are hidden.
+
+=back
+
=cut
sub edit_form {
my $prefill_with_default_values = $params->{prefill_with_default_values};
my $branch_limit = $params->{branch_limit};
my $default_branches_empty = $params->{default_branches_empty};
+ my $ignore_invisible_subfields = $params->{ignore_invisible_subfields} || 0;
my $libraries =
Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
if grep { $subfield->{kohafield} && $subfield->{kohafield} eq $_ }
@$kohafields_to_ignore;
+ next
+ if $ignore_invisible_subfields
+ && ( $subfield->{hidden} > 4 || $subfield->{hidden} <= -4 );
+
my $readonly;
if (
@$subfields_to_allow && !grep {
} @$subfields_to_allow
)
{
-
next if $ignore_not_allowed_subfields;
$readonly = 1 if $restricted_edition;
}
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use Test::More tests => 7;
+use Test::More tests => 8;
use Data::Dumper qw( Dumper );
use utf8;
is( $subfield, undef, "subfield that is not in the allow list is not returned" );
};
+subtest 'ignore_invisible_subfields' => sub {
+ plan tests => 2;
+
+ my $biblio =
+ $builder->build_sample_biblio( { value => { frameworkcode => '' } } );
+ my $item = $builder->build_sample_item(
+ {
+ issues => 42,
+ }
+ );
+
+ # items.issues is mapped with 952$l
+ my $subfields = Koha::UI::Form::Builder::Item->new(
+ {
+ biblionumber => $biblio->biblionumber,
+ item => $item->unblessed,
+ }
+ )->edit_form;
+ ( my $subfield ) = grep { $_->{subfield} eq 'l' } @$subfields;
+ is( $subfield->{marc_value}->{value}, 42, 'items.issues copied' );
+
+ $subfields = Koha::UI::Form::Builder::Item->new(
+ {
+ biblionumber => $biblio->biblionumber,
+ item => $item->unblessed,
+ }
+ )->edit_form(
+ {
+ ignore_invisible_subfields => 1
+ }
+ );
+ ($subfield) = grep { $_->{subfield} eq 'l' } @$subfields;
+ is( $subfield->{marc_value}->{value},
+ undef, 'items.issues not copied if ignore_invisible_subfields is passed' );
+};
$cache->clear_from_cache("MarcStructure-0-");
$cache->clear_from_cache("MarcStructure-1-");