Purpose
Submit and/or reset a form, using links/buttons that are outside the child DOM of the form.
Action | Purpose |
---|
reset | Reset the form |
submit | Submit the form |
Target | Purpose | Default |
---|
form (Optional) | The form to target the controller's actions on | - |
Value | Type | Description | Default |
---|
formSelector (Optional) | String | The CSS selector to find the form to remotely submit/reset | - |
submitMode (Optional) | String | The mode to submit the form using, either direct or request .
direct calls .submit() on the form without dispatching the submit event.
request synthesizes a normal submit event on the form, a submit event will still be fired and any listeners that modify the behaviours of the form will still run.
| request |
Events
Event | When | Dispatched on | event.detail |
---|
submit [Native Browser Event] | When the form is submitted, via the submit action | The form target. | - |
reset [Native Browser Event] | When the form is reset, via the reset action | The form target. | - |
Side Effects
- Adds event listeners for
change
or input
(depending on the value of eventModeValue
) to all <input>
<textarea>
and <select>
elements in the controller's scope.
- If the
submitModeValue
is request
and the browser does not support .requestSubmit()
, then the controller will use any existing submit buttons, or create a hidden submit button (which will be cleaned up on 'disconnect'), to submit the form by clicking on them.
See MSDN for details
How to Use
Option 1:
Put the controller in a scope that can see a formTarget
, and wire up some links with actions to form-rc#submit
,
Option 2:
Put the controller in a scope with some links with actions to form-rc#submit
, and a CSS selector
provided to the controller via formSelectorValue
that it can use to find the form in the page,