I am trying to set up a reactive/dynamic form in Perspective and am having a hard time with the visibility of data fields using "visibleWhen"
I have a field that is a dropdown (id=projectStatus) with values of Pending, Future, and Old. When Pending or Future are selected, I want to show a specific text box.
On the text box, I setup the visibleWhen with an id:projectStatus and value:Future, and it works...but I need it for "Future" and "Pending". I can't figure out an expression to use, but would love to know if anyone has had any luck with this?
Also, if a field is not visible, but required if it is shown, do I need to dynamically disable "required" based on the visible property? I think it blocks me from hitting the submit button.
All this to ask if I should just create a series of flex containers to replicate the form vs using the form component. I do like it, but it seems like I might be asking too much from it!
Thanks!
- Create a custom property on the view's properties. (Select the top level of the view in Project Browser.) Call it something like 'projectStatus'.
- Create a properting binding on the dropdown's value property. Bind it to the custom property above and make the binding bidirectional.
The purpose of the above is to give access to the variable from anywhere in the view without having to do 'getParent / getSibling' stuff which breaks when you move components in and out of containers.
- Now create an expression binding on the textbox's visibility property. The expression will be of the form:
({view.custom.projectStatus} = 'Future')
||
({view.custom.projectStatus} = 'Pending')
Thank you taking the time Transistor! You are correct on moving things around, thats always a pain.
Had that set up similarly to what you said when I was using the standard components/containers. I was trying to be slick and use the new 8.3 Form component. Based on the 8.3 docs, its looking for a object. I tried to add an array of values for the value field...but that didn't quite work.
The screenshot below works for Future.