EditGuideForm
extends FormBase
in package
Provides a form for editing a guide.
This form allows users to edit the title, description, subjects, type, group, and publication status of a guide. It dynamically adjusts available options based on the guide's current settings and taxonomy term availability.
Table of Contents
Methods
- access() : AccessResult
- Checks if the user can edit their own article.
- buildForm() : array<string|int, mixed>
- Builds the guide edit form.
- getFormId() : string
- {@inheritdoc}
- hideDescriptionCallback() : AjaxResponse
- AJAX callback for toggling the description field visibility.
- submitAjax() : AjaxResponse
- Handles AJAX form submission.
- submitForm() : void
- Processes the submission of the guide edit form.
- validateFields() : void
- Validates the form input.
Methods
access()
Checks if the user can edit their own article.
public
access(Request $request, AccountInterface $account) : AccessResult
Parameters
- $request : Request
- $account : AccountInterface
Return values
AccessResultbuildForm()
Builds the guide edit form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state) : 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.
Tags
Return values
array<string|int, mixed> —The form structure, including fields for editing guide properties.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringhideDescriptionCallback()
AJAX callback for toggling the description field visibility.
public
hideDescriptionCallback(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.
Return values
AjaxResponse —The AJAX response to handle form resizing.
submitAjax()
Handles AJAX form submission.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Processes the form submission via AJAX, providing a smoother user experience by offering immediate feedback without requiring a page refresh.
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 for the form submission.
submitForm()
Processes the submission of the guide edit form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Updates the guide node with the new values from the form. Handles the complexity of multiple and single value fields such as taxonomy terms and publication status.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.
validateFields()
Validates the form input.
public
validateFields(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Ensures the description is provided if the 'Hide description' checkbox is not checked.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.