ReOderBoxItemsForm
extends FormBase
in package
Form to reorder the items within a box.
This form utilizes a tabledrag interface for users to easily adjust the order of items within a selected box. The new order is then saved, reflecting the updated arrangement in the presentation layer.
Table of Contents
Methods
- access() : AccessResult
- Checks if the user can edit their own article.
- buildForm() : array<string|int, mixed>
- Builds the reorder box items form.
- getFormId() : string
- {@inheritdoc}
- submitAjax() : AjaxResponse
- AJAX callback for form submission.
- submitForm() : void
- Processes the submission of the reorder box items 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 reorder box items form.
public
buildForm(array<string|int, mixed> $form, FormStateInterface $form_state) : array<string|int, mixed>
Constructs the form elements necessary for displaying the items in a box and allows for their order to be changed via a drag-and-drop interface.
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 structure with reorder capabilities.
getFormId()
{@inheritdoc}
public
getFormId() : string
Return values
stringsubmitAjax()
AJAX callback for form submission.
public
submitAjax(array<string|int, mixed> &$form, FormStateInterface $form_state) : AjaxResponse
Provides immediate feedback through AJAX upon successful reordering of box items, enhancing user experience by avoiding full page reloads.
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 indicating success.
submitForm()
Processes the submission of the reorder box items form.
public
submitForm(array<string|int, mixed> &$form, FormStateInterface $form_state) : void
Applies the new order of items as specified by the user in the form to the actual box entity, ensuring the updated order is reflected site-wide.
Parameters
- $form : array<string|int, mixed>
-
The form array.
- $form_state : FormStateInterface
-
The state of the form.