| title | Forms, buttons and errors |
|---|---|
| sidebar_position | 1.1 |
<Forms.Form method="PATCH" action={`/articles/${article.id}`} model={article} files>
…
<Forms.Submit>Save</Forms.Submit>
</Forms.Form>Form is Onu's Form, with Laravel's conventions added:
PUT,PATCHandDELETEare sent asPOSTwith a_methodfield.- Non-GET forms get a
_tokenfield. filessetsenctype="multipart/form-data".modelbinds the fields inside, andoldgives them old input.
Without onSubmit, the form submits natively, like a Blade form. With onSubmit, return the request promise (axios, fetch or Inertia). A rejected 422 shows its errors under the fields, with an error summary at the top. With Inertia, pass errors={form.errors} and processing={form.processing}. All of Onu Form's props (labelLayout, summary, onSuccess, …) work.
| Component | Props |
|---|---|
Button |
color (primary, secondary, success, danger, warning, info, light, dark, link, outline-*), type, animate, Onu Button props |
Submit |
color. Shows a spinner on a valid submit (js-utilities' animate-submit) or while onSubmit runs |
LinkButton |
url, color |
ButtonGroup |
inline (default true; false stacks vertically) |
FormGroup wraps any control with a label, help and errors. Label, LabelRequired, InputHelp and Errors name="title" are the building blocks on their own.