Skip to content
ConsoleMonster
Cmdlet

New-ConsoleField

Module ConsoleMonster
Inputs
None
Outputs
ConsoleMonster.Interactive.Field

Creates a form field for New-ConsoleForm.

Syntax

New-ConsoleField [-ArgumentList <Object[]>] [-Choices <Object[]>] [-CommandPlaceholder <String>] [-Default <Object>] [-DependsOn <String[]>] [-Describe <Object>] [-Display <Object>] [-Extension <String[]>] [-GroupBy <Object>] [-Height <Int32>] [-Help <String>] [-Integer] [-Kind <Any|File|Folder>] [[-Label] <String>] [-LoadChoices <ScriptBlock>] [-Maximum <Decimal>] [-MaxLength <Int32>] [-MaxLines <Int32>] [-Minimum <Decimal>] [-MinLength <Int32>] [-MustExist] [-Name] <String> [-NoRemember] [-OffText <String>] [-OnText <String>] [-Page <String>] [-Parameter <String>] [-Pattern <String>] [-PatternMessage <String>] [-Placeholder <String>] [-Preview <ScriptBlock>] [-Required] [-Step <Decimal>] [-Type <ConsoleFieldType>] [-Validate <ScriptBlock>] [-VisibleWhen <ScriptBlock>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Creates a form field for New-ConsoleForm.

A field has a name (its key in the result), a label, help shown while it has focus, a default, validation (-Required, -Validate and the type's own checks) and the command-line parameter it supplies (-Parameter) for the equivalent command. -VisibleWhen shows it only while a condition on the other values holds ($Values). -DependsOn resets it when those fields change; with -LoadChoices its options are loaded again in their own runspace (a spinner shows, Esc cancels), from the current values ($Values).

Examples

Authored help example

EXAMPLE 1

New-ConsoleField -Name 'Name'

Parameters

-ArgumentList Object[] optional
More arguments for the -LoadChoices script.
-Choices Object[] optional
The choices of a Select or MultiSelect field (any objects).
-CommandPlaceholder String optional
What stands in for a secret in the equivalent command.
-Default Object optional
The default (for choices: the choice object or its text; for multi-selections: several).
-DependsOn String[] optional
Fields whose change resets this one (and reloads its choices).
-Describe Object optional
A sentence for the focused choice: a property name or a scriptblock.
-Display Object optional
What to show for a choice: a property name or a scriptblock.
-Extension String[] optional
File extensions offered as path suggestions.
-GroupBy Object optional
The group of a choice: a property name or a scriptblock.
-Height Int32 optional
The visible rows of the text area dialog (TextArea, default 8).
-Help String optional
Help shown while the field has focus.
-Integer SwitchParameter optional
Whole numbers only.
-Kind PathKind optional
What a path field accepts: Any, File or Folder.
Possible values: Any, File, Folder
-Label String optionalposition: 1
The label (default: the name).
-LoadChoices ScriptBlock optional
Loads the choices in their own runspace; the script gets the current values as $Values (and its first argument).
-Maximum Decimal optional
The largest number, or the most choices of a MultiSelect field.
-MaxLength Int32 optional
The most characters (TextArea).
-MaxLines Int32 optional
The most lines (TextArea).
-Minimum Decimal optional
The smallest number, or the fewest choices of a MultiSelect field.
-MinLength Int32 optional
The fewest characters of a text or secret field.
-MustExist SwitchParameter optional
Requires a path to exist.
-Name String requiredposition: 0
The key of the value in the result.
-NoRemember SwitchParameter optional
Keeps the value out of presets and remembered choices.
-OffText String optional
Text after a toggle that is off (default No).
-OnText String optional
Text after a toggle that is on (default Yes).
-Page String optional
The wizard page the field is on.
-Parameter String optional
The parameter the field supplies in the equivalent command (Name, -Name or --name).
-Pattern String optional
A pattern a text field must match.
-PatternMessage String optional
The message when -Pattern does not match.
-Placeholder String optional
Muted text while a text field is empty.
-Preview ScriptBlock optional
Preview content for the focused choice in the editor ($_ is the choice).
-Required SwitchParameter optional
Refuses an empty value.
-Step Decimal optional
The step of a number field.
-Type ConsoleFieldType optional
The kind: Text (default), Secret, Number, Toggle, Select, MultiSelect or Path.
Possible values: Text, Secret, Number, Toggle, Select, MultiSelect, Path, TextArea
-Validate ScriptBlock optional
A validator: $_ is the value, $Values the other values; return $true (or nothing), $false or an error message.
-VisibleWhen ScriptBlock optional
Shows the field only while this returns $true ($Values holds the other values).

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.