> 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/es/comandos-de-powershell/new-udform.md).

# New-UDForm

### Sinopsis

Los formularios pueden contener cualquier conjunto de controles de entrada. Cada uno de los controles informará de su valor al formulario cuando se haga clic en el botón de envío.

### Sintaxis

```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>]
```

### Descripción

Crea un nuevo formulario. Los formularios pueden contener cualquier conjunto de controles de entrada. Cada uno de los controles informará de su valor al formulario cuando se haga clic en el botón de envío.

### Parámetros

#### -Id

El ID del componente. Por defecto, es un GUID aleatorio.

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

#### -Children

Controles que componen este formulario. Puede ser cualquier combinación de controles. Los controles de entrada informarán de su estado al formulario.

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

#### -OnSubmit

Un bloque de script que se ejecuta cuando se envía el formulario. Puede devolver controles desde este bloque de script y el formulario será reemplazado por el bloque de script. La variable $EventData contendrá una hashtable con todos los campos de entrada y sus valores.

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

#### -OnValidate

Un bloque de script que valida el formulario. Devuelve el resultado de una llamada a New-UDFormValidationResult.

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

#### -OnProcessing

Un bloque de script que se llama cuando el formulario comienza a procesarse. El valor devuelto por este bloque de script debe ser un componente que muestre un cuadro de diálogo de carga. El bloque de script recibirá los datos actuales del formulario.

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

#### -OnCancel

Un bloque de script que se llama cuando se cancela un formulario. Útil para cerrar formularios en ventanas modales.

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

#### -SubmitText

Texto que se muestra dentro del botón de envío. Por defecto, es 'Submit'.

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

#### -CancelText

Texto que se muestra dentro del botón de cancelar. Por defecto, es 'Cancel'.

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

#### -ButtonVariant

Tipo de botón que se muestra. Por defecto, es text. Los valores válidos son contained, outlined, text.

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

#### -ClassName

Una clase CSS que se aplica al formulario.

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

#### -Schema

Define un formulario basado en una hashtable de esquema. Esta versión de los formularios se basa en react-jsonschema-form.

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

#### -UiSchema

Se utiliza para modificar el orden de los campos (consulte la documentación)

```
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

Se utiliza para generar automáticamente formularios basados en los scripts de su entorno de PowerShell Universal. Los formularios de script generarán componentes de entrada basados en el bloque param. Los formularios de script admiten automáticamente el progreso y la retroalimentación.

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

#### -OutputType

El tipo de salida que devuelve el script. Los valores válidos son: "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).
```

### Salidas

\-------------------------- EJEMPLO 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/es/comandos-de-powershell/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.
