diff --git a/src/Public/Elements.ps1 b/src/Public/Elements.ps1 index 4a9d3f83..98763a88 100644 --- a/src/Public/Elements.ps1 +++ b/src/Public/Elements.ps1 @@ -84,7 +84,10 @@ function New-PodeWebTextbox $NoAuthentication, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Textbox -Id $Id -Name $Name @@ -133,6 +136,7 @@ function New-PodeWebTextbox } NoAuthentication = $NoAuthentication.IsPresent NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } # create autocomplete route @@ -184,7 +188,10 @@ function New-PodeWebFileUpload $CssStyle, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag File -Id $Id -Name $Name @@ -199,6 +206,7 @@ function New-PodeWebFileUpload CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) NoEvents = $true NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } } @@ -379,7 +387,10 @@ function New-PodeWebCheckbox $Disabled, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Checkbox -Id $Id -Name $Name @@ -402,6 +413,7 @@ function New-PodeWebCheckbox CssClasses = ($CssClass -join ' ') CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } } @@ -436,7 +448,10 @@ function New-PodeWebRadio $Disabled, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Radio -Id $Id -Name $Name @@ -453,6 +468,7 @@ function New-PodeWebRadio CssClasses = ($CssClass -join ' ') CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } } @@ -499,7 +515,10 @@ function New-PodeWebSelect $Multiple, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Select -Id $Id -Name $Name @@ -524,6 +543,7 @@ function New-PodeWebSelect CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) NoAuthentication = $NoAuthentication.IsPresent NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } $routePath = "/components/select/$($Id)" @@ -597,7 +617,10 @@ function New-PodeWebRange $ShowValue, [switch] - $NoForm + $NoForm, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Range -Id $Id -Name $Name @@ -624,6 +647,7 @@ function New-PodeWebRange CssClasses = ($CssClass -join ' ') CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) NoForm = $NoForm.IsPresent + Required = $Required.IsPresent } } @@ -1137,7 +1161,10 @@ function New-PodeWebCredential $ReadOnly, [switch] - $NoLabels + $NoLabels, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag Cred -Id $Id -Name $Name @@ -1153,6 +1180,7 @@ function New-PodeWebCredential NoLabels = $NoLabels.IsPresent CssClasses = ($CssClass -join ' ') CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) + Required = $Required.IsPresent } } @@ -1184,7 +1212,10 @@ function New-PodeWebDateTime $ReadOnly, [switch] - $NoLabels + $NoLabels, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag DateTime -Id $Id -Name $Name @@ -1200,6 +1231,7 @@ function New-PodeWebDateTime NoLabels = $NoLabels.IsPresent CssClasses = ($CssClass -join ' ') CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle) + Required = $Required.IsPresent } } @@ -1255,7 +1287,10 @@ function New-PodeWebMinMax $ReadOnly, [switch] - $NoLabels + $NoLabels, + + [switch] + $Required ) $Id = Get-PodeWebElementId -Tag MinMax -Id $Id -Name $Name @@ -1285,6 +1320,7 @@ function New-PodeWebMinMax Text = $AppendText Icon = $AppendIcon } + Required = $Required.IsPresent } } diff --git a/src/Templates/Views/elements/checkbox.pode b/src/Templates/Views/elements/checkbox.pode index ef302e0d..137dc5b4 100644 --- a/src/Templates/Views/elements/checkbox.pode +++ b/src/Templates/Views/elements/checkbox.pode @@ -19,10 +19,15 @@ $checked = 'checked' } + $required = [string]::Empty + if ($data.Required) { + $required = "required" + } + for ($i = 0; $i -lt $data.Options.Length; $i++) { if ($data.AsSwitch) { "
- + @@ -30,7 +35,7 @@ } else { "
- + diff --git a/src/Templates/Views/elements/credential.pode b/src/Templates/Views/elements/credential.pode index 50e2dfdc..799ae28c 100644 --- a/src/Templates/Views/elements/credential.pode +++ b/src/Templates/Views/elements/credential.pode @@ -12,6 +12,11 @@ $readOnly = "readonly" } + $required = [string]::Empty + if ($data.Required) { + $required = "required" + } + $placeholder = [string]::Empty "
@@ -22,7 +27,7 @@ else { $placeholder = "placeholder='Username'" } - " + "
" if (!$data.NoLabels) { @@ -33,7 +38,7 @@ } "
- +
" diff --git a/src/Templates/Views/elements/datetime.pode b/src/Templates/Views/elements/datetime.pode index d65ba79b..085ce9ff 100644 --- a/src/Templates/Views/elements/datetime.pode +++ b/src/Templates/Views/elements/datetime.pode @@ -12,18 +12,23 @@ $readOnly = "readonly" } + $required = [string]::Empty + if ($data.Required) { + $required = "required" + } + "
" if (!$data.NoLabels) { "" } - " + "
" if (!$data.NoLabels) { "" } - " + "
" ) diff --git a/src/Templates/Views/elements/fileupload.pode b/src/Templates/Views/elements/fileupload.pode index 95f640a1..41b49740 100644 --- a/src/Templates/Views/elements/fileupload.pode +++ b/src/Templates/Views/elements/fileupload.pode @@ -3,7 +3,7 @@ "" })
- +
\ No newline at end of file diff --git a/src/Templates/Views/elements/minmax.pode b/src/Templates/Views/elements/minmax.pode index 0c15f70f..5bdca972 100644 --- a/src/Templates/Views/elements/minmax.pode +++ b/src/Templates/Views/elements/minmax.pode @@ -12,6 +12,11 @@ $readOnly = "readonly" } + $required = [string]::Empty + if ($data.Required) { + $required = "required" + } + $wrapped = ($data.Prepend.Enabled -or $data.Append.Enabled) $prepend = [string]::Empty @@ -46,7 +51,7 @@ } $element += $prepend - $element += "" + $element += "" $element += $append if ($wrapped) { @@ -66,7 +71,7 @@ } $element += $prepend - $element += "" + $element += "" $element += $append if ($wrapped) { diff --git a/src/Templates/Views/elements/radio.pode b/src/Templates/Views/elements/radio.pode index 91d9a43c..7da8b0a9 100644 --- a/src/Templates/Views/elements/radio.pode +++ b/src/Templates/Views/elements/radio.pode @@ -12,7 +12,7 @@ for ($i = 0; $i -lt $data.Options.Length; $i++) { "
- + diff --git a/src/Templates/Views/elements/range.pode b/src/Templates/Views/elements/range.pode index 610c8bd4..65b940f9 100644 --- a/src/Templates/Views/elements/range.pode +++ b/src/Templates/Views/elements/range.pode @@ -9,7 +9,7 @@ $showValue = 'pode-range-value' } - "" + "" if ($data.ShowValue) { "" diff --git a/src/Templates/Views/elements/select.pode b/src/Templates/Views/elements/select.pode index 2009ca02..ac6d4bb7 100644 --- a/src/Templates/Views/elements/select.pode +++ b/src/Templates/Views/elements/select.pode @@ -17,6 +17,7 @@ pode-object='$($data.ObjectType)' pode-dynamic='$($data.IsDynamic)' $($multiple) + $(if ($data.Required) { 'required' }) $(ConvertTo-PodeWebEvents -Events $data.Events) >" diff --git a/src/Templates/Views/elements/textbox.pode b/src/Templates/Views/elements/textbox.pode index cce73f17..5c283afa 100644 --- a/src/Templates/Views/elements/textbox.pode +++ b/src/Templates/Views/elements/textbox.pode @@ -16,6 +16,11 @@ $readOnly = "readonly" } + $required = [string]::Empty + if ($data.Required) { + $required = "required" + } + $value = [string]::Empty if (![string]::IsNullOrWhiteSpace($data.Value)) { $value = "value='$($data.Value)'" @@ -29,7 +34,7 @@ $events = ConvertTo-PodeWebEvents -Events $data.Events if ($data.Multiline) { - $element = "" + $element = "" } else { if ($data.Prepend.Enabled -or $data.Append.Enabled) { @@ -50,7 +55,7 @@ $_type = 'datetime-local' } - $element += "" + $element += "" if ($data.Append.Enabled) { if (![string]::IsNullOrWhiteSpace($data.Append.Text)) {