FormStateService
class FormStateService (View source)
Keeps submitted form data in the session so a failed request can refill the form.
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
Stash the zone editor's inline add-record form before processing, so a failed validation can re-display the submitted values.
Record why the stashed add-record submission was refused.
The stashed add-record values merged with their error, or null unless both are present. Non-destructive: the stash survives until the add succeeds or the zone changes.
Drop the stashed add-record form and its error, after a successful add.
Remember which zone the add-record stash belongs to, clearing it when the operator moves to a different zone so values never leak across zones.
Details
__construct(SessionInterface $session)
No description
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
void
rememberAddRecordForm(array $values)
Stash the zone editor's inline add-record form before processing, so a failed validation can re-display the submitted values.
These use the same session keys the zone editor always used, so the behaviour (and any in-flight sessions) are unchanged.
void
rememberAddRecordError(array $error)
Record why the stashed add-record submission was refused.
array|null
addRecordFormWithError()
The stashed add-record values merged with their error, or null unless both are present. Non-destructive: the stash survives until the add succeeds or the zone changes.
void
forgetAddRecordForm()
Drop the stashed add-record form and its error, after a successful add.
void
trackAddRecordZone(int $zoneId)
Remember which zone the add-record stash belongs to, clearing it when the operator moves to a different zone so values never leak across zones.