EditPageForm
extends FormBase
in package
Form for editing an individual page within a guide.
Allows users to modify page attributes such as title, description, and whether the description should be hidden. Users can also change the position of the page within the guide, update its draft status, and handle pages that are merely references to other content.
Table of Contents
Methods
- access() : AccessResult
- Checks if the user can edit their own article.
- buildForm() : array<string|int, mixed>
- Builds the page edit form.
- getFormId() : string
- {@inheritdoc}
- hideDescriptionCallback() : AjaxResponse
- AJAX callback for hiding the description field.
- selectPageCallBack() : array<string|int, mixed>
- AJAX callback for updating form elements based on the selected page.
- submitAjax() : AjaxResponse
- Handles AJAX submissions for the edit page form.
- submitForm() : void
- Processes the submission of the edit page form.
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 page 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 initial structure of the form.
- $form_state : FormStateInterface
-
The current state of the form.
Return values
array<string|int, mixed> —The modified form structure.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringhideDescriptionCallback()
AJAX callback for hiding the description field.
public
hideDescriptionCallback(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Adjusts the form to accommodate user preference regarding the visibility of the description field.
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The state of the form.
Return values
AjaxResponse —The response containing commands for the AJAX request.
selectPageCallBack()
AJAX callback for updating form elements based on the selected page.
public
selectPageCallBack(array<string|int, mixed> &$form, FormStateInterface $form_state) : array<string|int, mixed>
Dynamically updates the form fields to reflect the attributes of the selected page, allowing for immediate editing. This includes loading the page's title, description, and draft mode status.
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The state of the form.
Return values
array<string|int, mixed> —The updated portion of the form to be replaced.
submitAjax()
Handles AJAX submissions for the edit page form.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Provides a smooth user experience by processing form submissions via AJAX, offering immediate feedback without 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 for the form submission.
submitForm()
Processes the submission of the edit page form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Updates the selected page with the new values from the form. This includes changing the page's title, description, position within the guide, and publication status.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.