FormStateService
class FormStateService (View source)
Service class for managing form state across requests
This service handles storing and retrieving form data when validation errors occur, allowing form fields to retain their values after a failed submission.
Constants
| private SESSION_KEY |
|
| private EXPIRY_TIME |
|
Methods
Save form data to the session with an expiry time
Get form data from the session without removing it
Explicitly clear form data when it's no longer needed
Generate a unique form ID based on the current request
Get the latest form ID with a specified prefix
Details
void
saveFormData(string $formId, array $data)
Save form data to the session with an expiry time
array|null
getFormData(string $formId)
Get form data from the session without removing it
void
clearFormData(string $formId)
Explicitly clear form data when it's no longer needed
string
generateFormId(string $prefix = '')
Generate a unique form ID based on the current request
string|null
getLatestFormId(string $prefix)
Get the latest form ID with a specified prefix