ReOrderPagesForm
extends FormBase
in package
Provides a form to reorder child pages of a given node.
This form allows users to change the order of child pages for a specific parent node (guide or page), utilizing Drupal's drag-and-drop functionality to create an intuitive user experience.
Table of Contents
Methods
- access() : AccessResult
- Checks if the user can edit their own article.
- buildForm() : array<string|int, mixed>
- Builds the reorder pages form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- AJAX callback for the form submission.
- submitForm() : void
- Processes the submission of the reorder pages form.
- updateTable() : array<string|int, mixed>
- Callback function to update the form with a table of reorderable pages.
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 pages form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state) : array<string|int, mixed>
Parameters
- $form : array<string|int, mixed>
-
The initial form array.
- $form_state : FormStateInterface
-
The current state of the form.
Return values
array<string|int, mixed> —The modified form array with a tabledrag interface for reordering.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
AJAX callback for the form submission.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Handles the AJAX submission, providing a smooth experience by avoiding a full page reload and directly showing the results of reordering.
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 indicating success.
submitForm()
Processes the submission of the reorder pages form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Applies the new order of child pages as determined by the user, saving the updated order back to the parent node to ensure the changes are reflected.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.
Tags
updateTable()
Callback function to update the form with a table of reorderable pages.
public
updateTable(array<string|int, mixed> &$form, FormStateInterface $form_state) : array<string|int, mixed>
Triggered when the user selects a page to sort, dynamically updating the form to display the reorderable list of child pages.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The current state of the form.
Return values
array<string|int, mixed> —The updated portion of the form with the reorderable pages table.