This feature is experimental. Please share your experiences so we know what to keep or change.
Constructs a new up.Params
instance from the given <form>
.
The returned params may be passed as { params }
option to
up.request()
or up.replace()
.
The constructed up.Params
will include exactly those form values that would be
included in a regular form submission. In particular:
<input>
types are suppported<input type="file">
will produce
File
values.<input type="radio">
or <input type="checkbox">
will only be added if they are [checked]
.<select>
will only be added if at least one value is [checked]
.<select multiple>
or <input type="file" multiple>
, all selected values are added.
If passed a <select multiple>
, all selected values are added.[disabled]
are ignored[name]
attribute are ignored.Given this HTML form:
<form>
<input type="text" name="email" value="foo@bar.com">
<input type="password" name="pass" value="secret">
</form>
This would serialize the form into an array representation:
let params = up.Params.fromForm('input[name=email]')
let email = params.get('email') // email is now 'foo@bar.com'
let pass = params.get('pass') // pass is now 'secret'
A <form>
element.
A new up.Params
instance with values from the given form.