ReuseDatabaseForm
extends FormBase
in package
Provides a form to reuse existing database items.
Table of Contents
Methods
- buildForm() : array<string|int, mixed>
- Builds the reuse database item form.
- databaseItemSelectedAjaxCallback() : array<string|int, mixed>
- AJAX callback for when a database item is selected.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- AJAX callback for the form submission.
- submitForm() : void
- Handles the form submission.
- validateFields() : void
- Validates the form fields.
- prefillSelectedDatabaseItem() : void
- Fills in the form fields based on the selected database item.
Methods
buildForm()
Builds the reuse database item form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state[, $ids = null ]) : array<string|int, mixed>
Parameters
- $form : array<string|int, mixed>
-
The initial form array.
- $form_state : FormStateInterface
-
The current state of the form.
- $ids : = null
-
Contextual IDs or parameters passed to the form.
Return values
array<string|int, mixed> —The form array with elements to select and edit a database item.
databaseItemSelectedAjaxCallback()
AJAX callback for when a database item is selected.
public
databaseItemSelectedAjaxCallback(array<string|int, mixed> &$form, FormStateInterface $form_state) : array<string|int, mixed>
Dynamically updates the form based on the selected database item.
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The current state of the form.
Return values
array<string|int, mixed> —The part of the form to be updated.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
AJAX callback for the form submission.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Handles the form submission via AJAX, providing a smoother user experience.
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The current state of the form.
Tags
Return values
AjaxResponse —An AJAX response indicating success.
submitForm()
Handles the form submission.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Processes the reuse of the selected database item based on the form inputs.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.
Tags
validateFields()
Validates the form fields.
public
validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The current state of the form.
prefillSelectedDatabaseItem()
Fills in the form fields based on the selected database item.
private
prefillSelectedDatabaseItem(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The current state of the form.