You can configure Unpoly to handle every form on the page, without
annotating each form with an [up-submit] attribute.
Submissions then update fragments instead of loading full pages, and you need
fewer [up-...] attributes in your HTML.
Note
Links can be handled the same way. See Handling all links.
To submit all forms on a page without requiring an [up-submit] attribute:
up.form.config.submitSelectors.push('form')
Some forms will still submit with a full page load under this setting:
[up-submit=false] attribute.[target] attribute (to target an iframe or open a new browser tab).[action] attribute.up.form.config.noSubmitSelectors.Scripts that expect a full page load after every submission need adjusting, see Migrating legacy JavaScripts.
You can still make exceptions by setting an [up-submit=false] attribute on a form:
<form method="post" action="/report" up-submit="false"> <!-- mark: up-submit="false" -->
...
</form>
Submitting this form makes a full page load, as if Unpoly had not been loaded.
A single submit button can also opt for a full page load
by setting an [up-submit=false] attribute on the button:
<form method="post" action="/report/update">
<button type="submit" name="command" value="save">Save report</button>
<button type="submit" name="command" value="download" up-submit="false">Download PDF</button> <!-- mark: up-submit="false" -->
</form>
The form is still submitted through Unpoly when the user presses Save report. Only Download PDF loads a full page.
Instead of changing up.form.config.submitSelectors, you can register a macro
that sets [up-submit] on every form:
up.macro('form:not([up-submit=false])', function(form) {
form.setAttribute('up-submit', '')
})
Forms with [up-submit=false] are left alone. The exceptions above still apply:
forms with a [target] or a cross-origin [action] load a full page.
A macro can set other attributes in the same pass, like [up-disable]
to disable the form while it submits.
Tip Your coding agent can search these docs locally with the Unpoly agent skill