1 package Koha
::Object
::Mixin
::AdditionalFields
;
7 Koha::Object::Mixin::AdditionalFields
13 use parent qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
22 Koha::Foos->find($id)->set_additional_fields(...);
28 =head3 set_additional_fields
30 $foo->set_additional_fields([
43 sub set_additional_fields
{
44 my ($self, $additional_fields) = @_;
46 my $rs = Koha
::Database
->new->schema->resultset('AdditionalFieldValue');
48 foreach my $additional_field (@
$additional_fields) {
49 my $field_value = $rs->find_or_new({
50 field_id
=> $additional_field->{id
},
51 record_id
=> $self->id,
53 my $value = $additional_field->{value
};
55 $field_value->set_columns({ value
=> $value })->update_or_insert;
56 } elsif ($field_value->in_storage) {
62 =head3 additional_field_values
64 Returns additional field values
66 my @values = $foo->additional_field_values;
70 sub additional_field_values
{
73 return $self->_result->additional_field_values;
78 Koha Development Team <http://koha-community.org/>
80 =head1 COPYRIGHT AND LICENSE
82 Copyright 2018 BibLibre
84 This file is part of Koha.
86 Koha is free software; you can redistribute it and/or modify it under the
87 terms of the GNU General Public License as published by the Free Software
88 Foundation; either version 3 of the License, or (at your option) any later
91 Koha is distributed in the hope that it will be useful, but WITHOUT ANY
92 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
93 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
95 You should have received a copy of the GNU General Public License along
96 with Koha; if not, see <http://www.gnu.org/licenses>.