AddDatabaseForm
extends FormBase
in package
Provides a form for adding or editing database entries.
This form allows users to create new database nodes or edit existing ones with fields for title, link, proxy configuration, description, and more. The form dynamically adjusts based on user input, such as showing or hiding fields based on the selected options.
Table of Contents
Methods
- buildForm() : array<string|int, mixed>
- Builds the add/edit database form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- Handles AJAX form submissions.
- submitForm() : void
- Submits the add/edit database form.
- validateFields() : void
- Custom validation for the database form.
Methods
buildForm()
Builds the add/edit database 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) Identifiers needed for form construction.
Return values
array<string|int, mixed> —The form structure as an array.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
Handles AJAX form submissions.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Performs the form submission via AJAX, providing a user-friendly response without requiring a full page reload.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.
Tags
Return values
AjaxResponse —The AJAX response object.
submitForm()
Submits the add/edit database form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Processes the submitted form data, creating or updating the database node with the provided values.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.
Tags
validateFields()
Custom validation for the database form.
public
validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Ensures all required fields are filled out correctly, applying specific validations based on user input and form configuration.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.