Pode.Web
Pode.Web copied to clipboard
Allow empty string value to be supplied to Update-PodeWebTextbox
Currently if you supply an empty string -Value to Update-PodeWebTextbox it doesn't do anything. It would be more appropriate for this to instead clear the textbox - but only if the value is explicitly set to an empty string. If the value is left as the default $null it won't do anything - for the use case of only updating the textbox's ReadOnly/Disabled state and not the value.
# update value
Update-PodeWebTextbox -Name 'Example' -Value 'Hi!'
# update value to empty - ie: clear
Update-PodeWebTextbox -Name 'Example' -Value ''
# only update the readonly state - don't update the value, leave it as is
Update-PodeWebTextbox -Name 'Example' -ReadOnlyState Enabled
Another possibility, similar to #475, we could maybe use $PSBoundParameters to check if -Value was supplied or not, and if not deal with it accordingly. This would allow empty and null to be explicitly supplied and clear the textbox, but when -Value not supplied it does nothing.
I just tested $PSBoundParameters for none [switch] parameters and it should work as expected. So it should be possible to allow explicitly supplied null/empty strings to clear the textbox, and for the use case of not supplied -Value at all, we do nothing to the textbox's value.