# Forms

Forms can be created using the `Form` component. It can be a mix of various types of input components that bind to a PowerShell class type.

## Basic Form

A basic form requires a PowerShell class definition to define the object used as the model for the form. Below is an example of the script behind this Blazor app. It creates a PowerShell class, sets it to the $Model variable and then defines an event callback to invoke when the form is submitted.

```powershell
class MyClass {
    [string]$Str 
}

$Variables["Model"] = [MyClass]::new()

function Submit {
    param($EventArgs)

    $Message.Success($EventArgs.Model.Str)
}
```

To use the above PowerShell script in a form, you can use the following PSBlazor syntax.

```markup
<Row>
    <Form Model="$Model" OnFinish="Submit">
        <FormItem>
            <Input bind-Value="$Model.Str" />
        </FormItem>
        <FormItem>
            <Button HtmlType="Submit">Submit</Button>
        </FormItem>
    </Form>
</Row>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powershelluniversal.com/portal/portal-widgets/forms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
