CreateGuidePageForm
extends FormBase
in package
Provides a form for creating new guide page entities.
This form allows users to create a new page within a guide, specifying details such as the page title, position in the guide's structure, and whether the page should be published or saved in draft mode. Users can also choose to hide the page's description.
Table of Contents
Methods
- buildForm() : array<string|int, mixed>
- Builds the guide page creation form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- Handles AJAX form submissions.
- submitForm() : void
- Processes the submission of the guide page creation form.
- validateFields() : void
- Validates form fields before submission.
Methods
buildForm()
Builds the guide page creation 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 necessary for form construction.
Return values
array<string|int, mixed> —The form structure.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
Handles AJAX form submissions.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Provides a smoother user experience by submitting the form and providing feedback via AJAX, 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 —An AJAX response that updates the client-side state.
submitForm()
Processes the submission of the guide page creation form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Takes the input from the form, validates it, and uses it to create a new guide page node entity, setting its properties according to the form values.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.
Tags
validateFields()
Validates form fields before submission.
public
validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Ensures required fields are filled and validates specific conditions, such as the necessity of a description if it's not hidden.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.