Input that updates existing card

#1

Hi,

How can I have an input text box update an existing card with new information?

“New-UDInputAction -Content” ends up replacing the input box, so a page refresh is required when wanting to get some new information. I have gotten a bit further by using elements but would like to check here first before I spend more time on it.

Essentially I would like a text field where I can enter a user name, and an area that displays that persons details (while retaining the text field repeat the process additional times).

Thanks,

0 Likes

#2

I feel like New-UDElement -ID “elementid” and Set-UDElement -ID “elementid” -content { … }

Would be your best bet, you can put that inside of a card.

1 Like

#3

Hey @poglet - the answer from @Jacob-Evans should work, however there is the element alternative… with a caveat…

Firstly - Take a peek at: https://poshtools.com/2018/11/13/dynamically-updating-controls-with-sync-udelement/ - Using this, we should be able to ensure our CARD has an ID and ENDPOINT and then update the entire card to pull new data from an input endpoint as you specified.

$Session:DisplayName = "John Smith"

    New-UDCard -Id 'CardDisplayNameCARD' -Title 'DisplayName Card' -Endpoint {
         New-UDParagraph -Text $Session:DisplayName
    }
     
    New-UDInput -Title "Input testing" -Id "MyUserForm" -Content {
        New-UDInputField -Type 'textbox' -Name 'InputDisplayName' -Placeholder 'Name Here!'
 
    } -Endpoint {
 
        param($InputDisplayName)
         
        $Session:DisplayName = $InputDisplayName
 
         Sync-UDElement -Id 'CardDisplayNameCARD'       
    }

Sounds good right?! - well the caveat is that I am actually having problems getting to work at the moment. My Sync-UDElement is failing to find the ID of the card. When I actually use a different control like Grid this approach works great. I am researching why this is not working - but even if I put the card in a Row/Column I CAN sync the row/column OK but the card will only update on page refresh…

Likely I am just not familiar enough with the control, BUT I’ll keep you posted when I figure out what’s going on here.

0 Likes

#4

Lee,

This works for me. I wrap the stuff to be sync’d in a Div UDElement, and sync that.

$Session:DisplayName = "John Smith"

New-UDElement -Id 'OutputSection' -Tag Div -Endpoint {
        New-UDCard -Id 'CardDisplayNameCARD' -Title 'DisplayName Card' -Endpoint {
             New-UDParagraph -Text $Session:DisplayName
        }
    }
 
New-UDInput -Title "Input testing" -Id "MyUserForm" -Content {
    New-UDInputField -Type 'textbox' -Name 'InputDisplayName' -Placeholder 'Name Here!'

} -Endpoint {

    param($InputDisplayName)
     
    $Session:DisplayName = $InputDisplayName

     Sync-UDElement -Id 'OutputSection'       
}

Thanks,
Tim Curwick

0 Likes