Documentation

ReuseHTMLItemForm extends FormBase
in package

Provides a form to reuse an HTML item.

This form allows users to select an existing HTML item to duplicate or reference within another context, such as a different box or page.

Table of Contents

Methods

buildForm()  : array<string|int, mixed>
Builds the reuse HTML item form.
getFormId()  : string
{@inheritdoc}
htmlItemSelectedAjaxCallback()  : AjaxResponse
Handles AJAX callback for HTML item selection.
submitAjax()  : AjaxResponse
submitForm()  : void
Handles form submission.
validateFields()  : void
Validates the form submission.
prefillSelectedHtmlItem()  : void
Pre-fills the selected HTML item fields if one is selected.

Methods

buildForm()

Builds the reuse HTML 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) Additional identifiers for form construction.

Return values
array<string|int, mixed>

The form structure.

htmlItemSelectedAjaxCallback()

Handles AJAX callback for HTML item selection.

public htmlItemSelectedAjaxCallback(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse

Updates the form state based on the selected HTML item.

Parameters
$form : array<string|int, mixed>

The form render array.

$form_state : FormStateInterface

The form state.

Return values
AjaxResponse

The AJAX response.

submitAjax()

public submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Parameters
$form : array<string|int, mixed>
$form_state : FormStateInterface
Tags
throws
EntityMalformedException
Return values
AjaxResponse

submitForm()

Handles form submission.

public submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void

Duplicates or references the selected HTML item based on user input.

Parameters
$form : array<string|int, mixed>

The form render array.

$form_state : FormStateInterface

The form state.

Tags
throws
EntityStorageException

validateFields()

Validates the form submission.

public validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void

Ensures that a title is provided when not creating a reference.

Parameters
$form : array<string|int, mixed>

The form render array.

$form_state : FormStateInterface

The form state.

prefillSelectedHtmlItem()

Pre-fills the selected HTML item fields if one is selected.

private prefillSelectedHtmlItem(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.


        
On this page

Search results