New-UDInput Cancel button or custom buttons

Is if possible to have a “Cancel” button besides the “Submit” button?
Or have custom buttons with actions that can have access to the form fields?

Plus, can we have other elements other then New-UDInputField, like New-UDHtml, on a form?
And some tooltips on fields perhaps?

None of that is really built in. I’d suggest opening some GitHub issues for what you’d like to see. Would the cancel button just clear the values the user has entered?

Hi Adam,

Cancel would just act as escape really, nothing spectacular.
Having the ability to place other UD elements or use New-UDRow and New-UDColumn to format the layout would be great.
What I am looking for is a bit more UI and logic control of a Form really.

Tooltips on UD elements is also a nice addition I think. The Export and Refresh buttons on UDGrid already have that so it should be possible I think?

Now some other issue I just faced in New-UDInput.
New-UDInputField has a parameter called DefaultValue. I have noticed that the value I add via a variable is only shown correctly the 1st time I open the form. After that the value stays the same even if the variable is different. Just press escape on the form and open again. You should see a new value for $Name as we generate that each time but the form shows the first time generated value only. When I press Submit, that first value is posted to the Endpoint param $name and the next time you open the form the latest unique name is shown as you would like. But opening the form once more, escape, open, escape, etc will show the same value again and not the one I generate each time new.

So run code, $Name has value A
Form field shows value A
Close form (escape)
Run code again, $Name now has value B
Form field shows value A
Close form (escape)
Run code again, $Name now has value C
Form field shows value A


# Generate the unique name
$Name =  (Get-Date).Millisecond
# This Toast shows the correct new unique value every time
Show-UDToast -Message "$($Name)" -Duration 3000 -BackgroundColor Green

New-UDInput -Id "Form" -Content {
   # This shows the unique value correct once, after that it will only show the first value we had and not the next generated values for the variable $Name 
   New-UDInputField -Type "textbox" -Name "name" -Placeholder "Name" -DefaultValue $Name
} -Endpoint {
    # This will show the first time generated value for $Name, not the latest (if we escaped the Form)
    Show-UDToast -Message "$($Name)" -Duration 3000 -BackgroundColor Green

If the Endpoint is processed, the next time the Form opens it will show the correct latest unique value. If you do not submit but press escape to close the form, you will never get the latest unique value as generated, until you submit again (with the not expected first generated value of course)

I hope I explained it well enough

PS: using UD 2.7 on Windows PS5.1

Hi Adam,

I found the problem!

I had a call to Hide-UDModal inside the Endpoint of Show-UDModal but none outside the Endpoint.
So pressing Escape worked, that closed the form/modal but no actual call to Hide-UDModal iwas present in my code.
I am guessing Hide-UDModal does some cleanup and re-initialising of variables?
Figured it out while I was making a simple dashboard to show as example and my version worked and that triggered me in comparing the working with non-working versions.

So were all good now!

Question about the UI elements in a New-UDInput
Do you need me to do something or explain more or are you OK and have the items on a wish list already?

Cool! Glad you got it working. Can you please file any issues on GitHub that you’d like implemented? That’s the wish list we are keeping: