New-UDForm
Synopsis
Forms can contain any set of input controls. Each of the controls will report its value back up to the form when the submit button is clicked.
Syntax
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>]Description
Creates a new form. Forms can contain any set of input controls. Each of the controls will report its value back up to the form when the submit button is clicked.
Parameters
-Id
The ID of the component. It defaults to a random GUID.
Required? false
Position? named
Default value [Guid]::NewGuid().ToString()
Accept pipeline input? false
Aliases
Accept wildcard characters? false-Children
Controls that make up this form. This can be any combination of controls. Input controls will report their state to the form.
-OnSubmit
A script block that is execute when the form is submitted. You can return controls from this script block and the form will be replaced by the script block. The $EventData variable will contain a hashtable of all the input fields and their values.
-OnValidate
A script block that validates the form. Return the result of a call to New-UDFormValidationResult.
-OnProcessing
A script block that is called when the form begins processing. The return value of this script block should be a component that displays a loading dialog. The script block will receive the current form data.
-OnCancel
A script block that is called when a form is cancelled. Useful for closing forms in modals.
-SubmitText
Text to show within the submit button. Defaults to 'Submit'.
-CancelText
Text to show within the cancel button. Defaults to 'Cancel'.
-ButtonVariant
Type of button to display. Defaults to text. Valid values are contained, outlined, text.
-ClassName
A CSS class to apply to the form.
-Schema
Defines a form based on a hashtable of schema. This version of forms is based on react-jsonschema-form.
-UiSchema
Used to modify the ordering of the fields (see documentation)
-FormData
-DisableSubmitOnEnter
Disables the functionality where pressing enter in a textbox submits the form it is a part of.
-Script
Used to automatically generate forms based on scripts in your PowerShell Universal environment. Script forms will generate input components based on the param block. Script forms automatically support progress and feedback.
-OutputType
The type of output to return from the script. Valid values are: "Text", "Table"
-ShowBackButton
Shows a back button after the form is submitted. This is only used for script forms.
Common parameters
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters.
Outputs
Examples
Example 1: Basic
Creates a basic form.
Example 2: Validation
Creates a form with validation.
Example 3: Processing
Creates a form with a processing dialog.
Example 4: Cancel
Creates a form with a cancel button.
Example 5: Submit and Cancel Text
Creates a form with custom submit and cancel text.
Example 6: Button Variant
Creates a form with a contained button variant.
Example 7: Class Name
Creates a form with a custom CSS class name.
Example 8: 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: 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: 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
Example 12
Last updated
Was this helpful?