AddHTMLForm
extends FormBase
in package
Provides a form for adding or editing HTML content items.
This form allows users to input and save HTML content as part of custom content structures within the site, like guides or tutorials. It supports creating new HTML items or editing existing ones, with features to save as draft or publish.
Table of Contents
Methods
- buildForm() : array<string|int, mixed>
- Builds the HTML item add/edit form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- AJAX form submission handler.
- submitForm() : void
- Handles the submission of the HTML form.
Methods
buildForm()
Builds the HTML item add/edit form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state[, mixed $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 : mixed = null
-
Optional parameters for form construction, such as the IDs of items to edit.
Return values
array<string|int, mixed> —The form structure.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
AJAX form submission handler.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Provides an AJAX callback for the form submission, enabling a more dynamic and responsive user interface.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.
Tags
Return values
AjaxResponse —An AJAX response that can include commands like modal close and re-render.
submitForm()
Handles the submission of the HTML form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Processes the form values to either create a new HTML item node or update an existing one. It ensures all HTML content is properly saved and linked within the system.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.