Repository navigation
Submit queue
Add submit-queue to a form to coordinate its background requests without application JavaScript.
<form id="settings" method="post" data-flux="auto submit-queue">
<label>Title <input name="title" required></label>
<button name="do" value="save">Save</button>
</form>auto enables background submission and replaces the form with the server's response. submit-queue adds these rules:
- Only one request per form runs at a time.
- Repeated clicks on the active action are ignored.
- During an automatic request, one different submit action can wait. The first waiting action wins. Clicks during an explicit submission are ignored.
- Fields are held while a request is running. Text fields stay focusable and read-only; choices and file inputs are disabled. Their values are included in the request. Existing states are restored afterwards.
- The form has
aria-busy="true"while its request runs. The usual.flux-form-waitingand.flux-button-waitingclasses still apply.
A preview is an ordinary server action. It renders the submitted draft without saving it:
<section data-flux="update">
<form id="deployment" method="post" data-flux="submit-queue">
<input type="hidden" name="csrf-token" value="server-token">
<label>Host <input name="host" required></label>
<button name="do" value="save">Save</button>
<button name="do" value="preview" data-flux="autosave" formnovalidate>
Update preview
</button>
</form>
</section>When a field changes, autosave submits do=preview. If the user clicks Save while that preview is running, Flux waits for the response to render, finds the refreshed form and submits its Save button. This uses the new field values and hidden tokens, rather than a copy of the earlier request.
The server remains responsible for deciding what a preview or save does. It must validate and authorise every request.
Flux uses the form's id, or its DOM path when there is no ID. Give forms stable IDs when their position can change.
The returned document must contain the matching form with submit-queue still set. Flux only replays a waiting action if its button remains present and enabled and the refreshed form passes normal browser validation. formnovalidate still works on the relevant button.
A network or HTTP error cancels the waiting action. Flux restores the controls and leaves retrying to the user. Removing the form, command or button in the response also cancels the waiting action.
Without JavaScript, all buttons remain ordinary submit buttons. The preview button is visible and requests a normal server-rendered preview.
This command is opt-in and is unreleased. It is tested at commit 9f4d68e05777739d508246e4f92b79a0f372dc49 on the submit-queue branch. Older versions report an unknown directive. Load the updated Flux script before adding the command.
PHP.GT/Flux is a separately maintained component of PHP.GT/WebEngine.