Creates an action for progressively enhanced forms that handles validation and submission on the server.
// Form action for simple forms
formAction$<Values, ResponseData>(action, validate);
// Form actions for complex forms
formAction$<Values, ResponseData>(action, options);
If you use TypeScript, you should define your field values. This way the library knows exactly which fields your form has and what values they expect. It also allows autocompletion and TypeScript notifies you of typos.
It is recommended to use
interfaceas this currently requires an explicit index signature in TypeScript. More about this here.
FormActionResult | void>
action function is only executed if the form values have passed the validation. Since
validate is executed on the server, the validation cannot be manipulated by the user. You can use the
action function to process the form values and store them in a database, for example. Also you can manipulate the state of the form action via the return value or send a message to the client via the