> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udform.md).

# New-UDForm

### Übersicht

Formulare können beliebige Kombinationen von Eingabesteuerelementen enthalten. Jedes dieser Steuerelemente meldet seinen Wert an das Formular zurück, wenn auf die Absenden-Schaltfläche geklickt wird.

### Syntax

```powershell
New-UDForm [-Id <String>] [-OnValidate <Endpoint>] [-SubmitText <String>] [-CancelText <String>] [-ButtonVariant <String>] [-ClassName <String>] [-DisableSubmitOnEnter] [-Script <String>] [-OutputType <String>] [-ShowBackButton] [<CommonParameters>]

    New-UDForm [-Id <String>] -Children <ScriptBlock> -OnSubmit <Endpoint> [-OnValidate <Endpoint>] [-OnProcessing <ScriptBlock>] [-OnCancel <Endpoint>] [-SubmitText <String>] [-CancelText <String>] [-ButtonVariant <String>] [-ClassName <String>] [-DisableSubmitOnEnter] [<CommonParameters>]

    New-UDForm [-Id <String>] -OnSubmit <Endpoint> [-ButtonVariant <String>] [-ClassName <String>] -Schema <Hashtable> [-UiSchema <Hashtable>] [-FormData <Hashtable>] [-DisableSubmitOnEnter] [<CommonParameters>]
```

### Beschreibung

Erstellt ein neues Formular. Formulare können beliebige Kombinationen von Eingabesteuerelementen enthalten. Jedes dieser Steuerelemente meldet seinen Wert an das Formular zurück, wenn auf die Absenden-Schaltfläche geklickt wird.

### Parameter

#### -Id

Die ID der Komponente. Standardmäßig eine zufällige GUID.

```
Required?                    false
Position?                    named
Default value                [Guid]::NewGuid().ToString()
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Children

Steuerelemente, aus denen dieses Formular besteht. Dies kann eine beliebige Kombination von Steuerelementen sein. Eingabesteuerelemente melden ihren Status an das Formular.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnSubmit

Ein Skriptblock, der ausgeführt wird, wenn das Formular abgesendet wird. Sie können Steuerelemente aus diesem Skriptblock zurückgeben, und das Formular wird durch den Skriptblock ersetzt. Die Variable $EventData enthält eine Hashtable aller Eingabefelder und ihrer Werte.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnValidate

Ein Skriptblock, der das Formular validiert. Geben Sie das Ergebnis eines Aufrufs von New-UDFormValidationResult zurück.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnProcessing

Ein Skriptblock, der aufgerufen wird, wenn das Formular mit der Verarbeitung beginnt. Der Rückgabewert dieses Skriptblocks sollte eine Komponente sein, die einen Ladedialog anzeigt. Der Skriptblock erhält die aktuellen Formulardaten.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnCancel

Ein Skriptblock, der aufgerufen wird, wenn ein Formular abgebrochen wird. Nützlich zum Schließen von Formularen in Modals.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -SubmitText

Text, der in der Absenden-Schaltfläche angezeigt wird. Standardmäßig 'Submit'.

```
Required?                    false
Position?                    named
Default value                Submit
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -CancelText

Text, der in der Abbrechen-Schaltfläche angezeigt wird. Standardmäßig 'Cancel'.

```
Required?                    false
Position?                    named
Default value                Cancel
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ButtonVariant

Art der anzuzeigenden Schaltfläche. Standardmäßig text. Gültige Werte sind contained, outlined, text.

```
Required?                    false
Position?                    named
Default value                text
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ClassName

Eine CSS-Klasse, die auf das Formular angewendet wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Schema

Definiert ein Formular basierend auf einer Hashtable mit Schema. Diese Version von Formularen basiert auf react-jsonschema-form.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -UiSchema

Wird verwendet, um die Reihenfolge der Felder zu ändern (siehe Dokumentation)

```
Required?                    false
Position?                    named
Default value                @{}
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -FormData

```
Required?                    false
Position?                    named
Default value                @{}
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false

    -DisableSubmitOnEnter [<SwitchParameter>]
        Disables the functionality where pressing enter in a textbox submits the form it is a part of.

Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Script

Wird verwendet, um Formulare automatisch basierend auf Skripten in Ihrer PowerShell Universal-Umgebung zu generieren. Skriptformulare generieren Eingabekomponenten basierend auf dem param-Block. Skriptformulare unterstützen automatisch Fortschritt und Rückmeldungen.

```
Required?                    false
Position?                    named
Default value                None
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OutputType

Der Typ der Ausgabe, die vom Skript zurückgegeben wird. Gültige Werte sind: "Text", "Table"

```
Required?                    false
Position?                    named
Default value                Text
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false

    -ShowBackButton [<SwitchParameter>]
        Shows a back button after the form is submitted. This is only used for script forms.

Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
```

### Ausgaben

\-------------------------- EXAMPLE 1 --------------------------

```
PS >New-UDForm -Id 'form1' -Content {
PS >     New-UDTextbox -Id 'form1Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form1Textbox)
PS > }

Basic|Creates a basic form.




-------------------------- EXAMPLE 2 --------------------------

PS >New-UDForm -Id 'form2' -Content {
PS >     New-UDTextbox -Id 'form2Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form2Textbox)
PS > } -OnValidate {
PS >     if ($EventData.form2Textbox -eq 'Bob') {
PS >         New-UDValidationResult -ValidationError 'Bob is not allowed'
PS >     }
PS >     else {
PS >         New-UDValidationResult -Valid
PS >     }
PS > }

Validation|Creates a form with validation.




-------------------------- EXAMPLE 3 --------------------------

PS >New-UDForm -Id 'form3' -Content {
PS >     New-UDTextbox -Id 'form3Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Start-Sleep -Seconds 5
PS >     Show-UDToast -Message ($EventData.form3Textbox)
PS > } -OnProcessing {
PS >     New-UDCard -Title 'Processing' -Content {
PS >         New-UDProgress
PS >     }
PS > }

Processing|Creates a form with a processing dialog.




-------------------------- EXAMPLE 4 --------------------------

PS >New-UDForm -Id 'form4' -Content {
PS >     New-UDTextbox -Id 'form4Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form4Textbox)
PS > } -OnCancel {
PS >     Show-UDToast -Message 'Form was cancelled'
PS > }

Cancel|Creates a form with a cancel button.




-------------------------- EXAMPLE 5 --------------------------

PS >New-UDForm -Id 'form5' -Content {
PS >     New-UDTextbox -Id 'form5Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form5Textbox)
PS > } -SubmitText 'Save' -CancelText 'Close' -OnCancel {
PS >     Show-UDToast -Message 'Form was cancelled'
PS > }

Submit and Cancel Text|Creates a form with custom submit and cancel text.




-------------------------- EXAMPLE 6 --------------------------

PS >New-UDForm -Id 'form6' -Content {
PS >     New-UDTextbox -Id 'form6Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form6Textbox)
PS > } -ButtonVariant 'contained'

Button Variant|Creates a form with a contained button variant.




-------------------------- EXAMPLE 7 --------------------------

PS >New-UDForm -Id 'form7' -Content {
PS >     New-UDTextbox -Id 'form7Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form7Textbox)
PS > } -ClassName 'my-form'

Class Name|Creates a form with a custom CSS class name.




-------------------------- EXAMPLE 8 --------------------------

PS >New-UDForm -Id 'form8' -Schema @{
PS >     title = "Test Form"
PS >     type = "object"
PS >     properties = @{
PS >        name = @{
PS >            type = "string"
PS >        }
PS >        age = @{
PS >            type = "number"
PS >        }
PS >     }
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.name)
PS >     Show-UDToast -Message ($EventData.age)
PS > }

Schema|Creates a form with a schema. You can find out more about JSON Schema here: https://rjsf-team.github.io/react-jsonschema-form/docs/




-------------------------- EXAMPLE 9 --------------------------

PS >New-UDForm -Id 'form9' -Schema @{
PS >     title = "Test Form"
PS >     type = "object"
PS >     properties = @{
PS >        name = @{
PS >            type = "string"
PS >        }
PS >        age = @{
PS >            type = "number"
PS >        }
PS >     }
PS > } -uiSchema @{
PS >	"ui:order" = @('age','name')
PS > } -FormData @{ Name = "adam"; Age = 38 } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.name)
PS > }

UI Schema|Creates a form with a schema and a UI schema. You can find out more about JSON Schema here: https://rjsf-team.github.io/react-jsonschema-form/docs/




-------------------------- EXAMPLE 10 --------------------------

PS >New-UDForm -Id 'form10' -Script "Script1.ps1" -OutputType "Table"

Script|Creates a form from a script. Parameters of the script will define the form. Output from the script will be displayed in a table.




-------------------------- EXAMPLE 11 --------------------------

PS >New-UDForm -Id 'form11' -Content {
PS >    New-UDTextbox -Id 'form11Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form11Textbox)
PS > }
PS > New-UDButton -Text "A submit button outside the form" -OnClick {
PS >     Invoke-UDForm -Id "form11"
PS > }

Invoke-UDForm|Creates a form with a submit button outside the form.




-------------------------- EXAMPLE 12 --------------------------

PS >New-UDForm -Id 'form12' -Content {
PS >    New-UDTextbox -Id 'form12Textbox' -Label 'Name'
PS > } -OnSubmit {
PS >     Show-UDToast -Message ($EventData.form12Textbox)
PS > } -OnValidate {
PS >     if ($EventData.form12Textbox -eq 'Hello') {
PS >         New-UDValidationResult -Valid
PS >     }
PS >     else {
PS >         New-UDValidationResult -ValidationError "Name must be 'Hello'"
PS >     }
PS > }
PS > New-UDButton -Text "Validate form" -OnClick {
PS >     Test-UDForm -Id "form12"
PS > }

Test-UDForm|Creates a form with a validate button outside the form.
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udform.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
