Previously, I’ve created a somewhat dynamic form so that when a user checks a box, or chooses something from a NativeSelect, I can make areas appear/disappear that make sense based on those selections. It works fine as long as the fields themselves don’t need to move or change their input type.
I have a new requirement for a Form that has a NativeSelect that defines the object’s “type”. In this case, it’s not enough to just make other fields appear/disappear. Instead, I want to actually have a changing layout, such as something like this (where [Field]
is used to represent a form field):
+++
[Type NativeSelect]
[Name TextField]
[Align NativeSelect]
[InitialValue TextField]
[Tooltip TextField]
[InputFormat TextField]
[OutputFormat TextField]
+++
Then, when the user uses the Type select box to change to another type, I need to relayout the form like:
+++
[Type NativeSelect]
[Name TextField]
[Align NativeSelect]
[OutputFormat NativeSelect]
[Tooltip TextField]
+++
So, I have removed the [InitialValue TextField]
as well as the [InputFormat TextField]
, and the [OutputFormat TextField]
is now a NativeSelect (still sets a String value in my item, one is just free form, while the other is constrained by the select box’s choices) and has moved up a row.
Can a Form be made to do this? I’ve been trying to trick the Form by rebuilding it entirely through setItemDataSource(), but it’s not really working, even after I beat it from getting stuck in loops. I think I am going about this the wrong way, and wondered if there is a right way, or whether this cannot be done. I prefer not to have a popup “type-specific” editor to handle this as it puts the type-specific fields out of initial view – something I only want to do for “detail configuration” that most users can ignore.
Thanks for any ideas!