ReuseBookForm
extends FormBase
in package
Provides a form to reuse a book item.
This form allows users to either duplicate a book item for reuse in a different context or create a reference to an existing book item, making it un-editable in the new context.
Table of Contents
Methods
- bookItemSelectedAjaxCallback() : array<string|int, mixed>
- AJAX callback for when a book item is selected.
- buildForm() : array<string|int, mixed>
- Builds the reuse book item form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- submitForm() : void
- Handles form submission.
- validateFields() : void
- Validates the form submission.
- prefillSelectedBookItem() : void
- Pre-fills the selected book item fields for the form.
Methods
bookItemSelectedAjaxCallback()
AJAX callback for when a book item is selected.
public
bookItemSelectedAjaxCallback(array<string|int, mixed> &$form, FormStateInterface $form_state) : array<string|int, mixed>
Updates the form state based on the selected book item.
Parameters
- $form : array<string|int, mixed>
-
The form render array.
- $form_state : FormStateInterface
-
The form state.
Return values
array<string|int, mixed> —The updated form element or elements.
buildForm()
Builds the reuse book item form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state[, array<string|int, mixed>|null $ids = null ]) : array<string|int, mixed>
Parameters
- $form : array<string|int, mixed>
-
An associative array containing the structure of the form.
- $form_state : FormStateInterface
-
The current state of the form.
- $ids : array<string|int, mixed>|null = null
-
(optional) Identifiers for form construction, such as the current node or box IDs.
Tags
Return values
array<string|int, mixed> —The form structure.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Parameters
- $form : array<string|int, mixed>
- $form_state : FormStateInterface
Tags
Return values
AjaxResponsesubmitForm()
Handles form submission.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Duplicates or references the selected book item based on user input.
Parameters
- $form : array<string|int, mixed>
-
The form render array.
- $form_state : FormStateInterface
-
The form state.
Tags
validateFields()
Validates the form submission.
public
validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Ensures that required fields are filled and specific conditions are met.
Parameters
- $form : array<string|int, mixed>
-
The form render array.
- $form_state : FormStateInterface
-
The form state.
prefillSelectedBookItem()
Pre-fills the selected book item fields for the form.
private
prefillSelectedBookItem(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Parameters
- $form : array<string|int, mixed>
-
The form definition array.
- $form_state : FormStateInterface
-
The current state of the form.