ReOrderBoxesForm
extends FormBase
in package
Form for reordering boxes within a guide or page.
This form allows users to adjust the order of content boxes within a guide or page, facilitating a flexible arrangement of content to improve the reader's experience. It utilizes a drag-and-drop interface for intuitive interaction.
Table of Contents
Methods
- access() : AccessResult
- Checks if the user can edit their own article.
- buildForm() : array<string|int, mixed>
- Builds the reorder boxes form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- AJAX callback for the reorder form submission.
- submitForm() : void
- Handles the form submission.
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 reorder boxes form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state) : array<string|int, mixed>
Parameters
- $form : array<string|int, mixed>
-
The initial form structure.
- $form_state : FormStateInterface
-
The current state of the form.
Return values
array<string|int, mixed> —The form array with elements for reordering boxes.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
AJAX callback for the reorder form submission.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Facilitates a smoother user experience by using AJAX to submit the reorder operation, avoiding the need for a full page reload and providing immediate feedback to the user.
Parameters
- $form : array<string|int, mixed>
-
The form structure.
- $form_state : FormStateInterface
-
The current state of the form.
Tags
Return values
AjaxResponse —An AJAX response for the submission.
submitForm()
Handles the form submission.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Processes the new order of boxes as determined by the user and saves this order back to the database, ensuring the display order matches the user's preference.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.