<<

NAME

Koha::UI::Form::Builder::Item

Helper to build a form to add or edit a new item.

API

Class methods

new

    my $form = Koha::UI::Form::Builder::Item->new(
        {
            biblionumber => $biblionumber,
            item => $current_item,
        }
    );

Constructor. biblionumber should be passed if we are creating a new item. For edition, an hashref representing the item to edit item must be passed.

generate_subfield_form

Generate subfield's info for given tag, subfieldtag, etc.

edit_form

    my $subfields =
      Koha::UI::Form::Builder::Item->new(
        { biblionumber => $biblionumber, item => $current_item } )->edit_form(
        {
            branchcode           => $branchcode,
            restricted_editition => $restrictededition,
            (
                @subfields_to_prefill
                ? ( subfields_to_prefill => \@subfields_to_prefill )
                : ()
            ),
            prefill_with_default_values => 1,
            branch_limit => C4::Context->userenv->{"branch"},
        }
    );

Returns the list of subfields to display on the add/edit item form.

Use it in the view with: [% PROCESS subfields_for_item subfields => subfields %]

Parameters:

branchcode

Pre-select a library (for logged in user)

restricted_editition

Flag to restrict the edition if the user does not have necessary permissions.

subfields_to_prefill

List of subfields to prefill (value of syspref SubfieldsToUseWhenPrefill)

If empty all subfields will be prefilled. For none, you can pass an array with a single false value.

subfields_to_allow

List of subfields to allow (value of syspref SubfieldsToAllowForRestrictedBatchmod or SubfieldsToAllowForRestrictedEditing)

ignore_not_allowed_subfields

If set, the subfields in subfields_to_allow will be ignored (ie. they will not be part of the subfield list. If not set, the subfields in subfields_to_allow will be marked as readonly.

kohafields_to_ignore

List of subfields to ignore/skip

prefill_with_default_values

Flag to prefill with the default values defined in the framework.

branch_limit

Limit info depending on the library (so far only item types).

default_branches_empty

Flag to add an empty option to the library list.

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.

<<