---
title: Auto Form Components
group: Component Gallery
---
## AutoForm
The `AutoForm` component is a generic form component that can be used to create and wire a traditional Form for any Request DTO definition
where successful responses can be handled the `@success` event, e.g:
```html
Results
```
Results
These Auto Form components are customizable with the [declarative C# UI Attributes](/locode/declarative#ui-metadata-attributes) where you can
override the form's **heading** with `[Description]` and include a **subHeading** with `[Notes]` which supports rich HTML markup.
**AutoForm Properties**
Alternatively they can be specified in the components properties:
```ts
defineProps<{
type: string|InstanceType|Function
modelValue?: ApiRequest|any
heading?: string
subHeading?: string
showLoading?: boolean
jsconfig?: string //= eccn,edv
configureField?: (field:InputProp) => void
/* Default Styles */
formClass?: string //= shadow sm:rounded-md
innerFormClass?: string
bodyClass?: string
headerClass?: string //= p-6
buttonsClass?: string //= mt-4 px-4 py-3 bg-gray-50 dark:bg-gray-900 sm:px-6 flex justify-between
headingClass?: string //= text-lg font-medium leading-6 text-gray-900 dark:text-gray-100
subHeadingClass?: string
submitLabel?: string //= Submit
}>()
```
Both `@success` and `@error` events are fired after each API call, although built-in validation binding means it's typically unnecessary to manually
handle error responses.
```ts
defineEmits<{
(e:'success', response:any): void
(e:'error', error:ResponseStatus): void
(e:'update:modelValue', model:any): void
}>()
```
**Model Binding**
Forms can be bound to a Request DTO model where it can be used to pre-populate the Forms default values and Request DTO whereby specifying a **type**
is no longer necessary:
```ts
```
## Create Form
`AutoCreateForm` can be used to create an automated form based on a [AutoQuery CRUD](/autoquery/crud) Create Request DTO definition which can be rendered in a traditional inline Form with **card** formStyle option, e.g:
```html
```
By default Auto Forms are rendered in a `SlideOver` dialog:
```html
```
These Auto Forms are powered by the rich [App Metadata](/vue/use-metadata) surrounding your APIs,
which contain all the necessary metadata to invoke the API and bind any contextual validation errors adjacent to the invalid field inputs.
## Edit Form
`AutoEditForm` can be used to render an automated form based on Update and Delete
[AutoQuery CRUD](/autoquery/crud) APIs which also makes use of **heading** and **sub-heading** customization options:
```html
```
The same form rendered in a traditional inline form with a **card** formStyle with some more advanced
customization examples using rich markup in custom `` and `` slots:
```html
Change an existing Room Booking
Here are some
good tips on making room reservations
```
Change an existing Room Booking
Here are some good tips on making room reservations
The forms behavior and appearance is further customizable with the
[API annotation](/locode/declarative#annotate-apis), declarative [validation](/locode/declarative#type-validation-attributes)
and the custom [Field and Input](/locode/declarative#custom-fields-and-inputs) attributes, e.g:
```csharp
[Description("Update an existing Booking")]
[Notes("Find out how to create a C# Bookings App from Scratch")]
[Route("/booking/{Id}", "PATCH")]
[ValidateHasRole("Employee")]
[AutoApply(Behavior.AuditModify)]
public class UpdateBooking : IPatchDb, IReturn
{
public int Id { get; set; }
public string? Name { get; set; }
public RoomType? RoomType { get; set; }
[ValidateGreaterThan(0)]
public int? RoomNumber { get; set; }
[ValidateGreaterThan(0)]
public decimal? Cost { get; set; }
public DateTime? BookingStartDate { get; set; }
public DateTime? BookingEndDate { get; set; }
[Input(Type = "textarea")]
public string? Notes { get; set; }
public string? CouponId { get; set; }
public bool? Cancelled { get; set; }
}
```
Where they can be used to customize Auto Form's appearance from annotations on C# Server DTOs:
```html
```
## Form Fields
For more advanced customization of a Forms appearance and behavior, `AutoFormFields` can be used to just render the Form's fields (with validation binding) inside a custom Form which can submit the data-bound populated Request DTO to invoke the API, e.g:
```html
```
`toFormValues` is used when updating the data bound `request` DTO to convert API response values into the required format that HTML Inputs expect.