Selectively Enable a Field
Within a form (simple or dynamic), you can disable a field by default, and enable it only after a certain action or event occurs within the page.
- An input field for the name of the theater
- A list of values (LOV) for the city where the theater is located
- An LOV for the new theater's capacity.
In this scenario, you want the Capacity field disabled by default (that is, grayed out), like this:
After the user selects a city, the Capacity field becomes active so the user can select a value:
When you want something to happen on a page based on the behavior of another component, either on that page or elsewhere, it almost always involves an action chain. Let's focus on how action chains work as we go through this scenario, so that you can apply your understanding to future use cases as well.
Note:
If you're working with a dynamic form, you'll need to work with its rule set to achieve the effect you want. See Selectively Display a Field to get an idea of how to do that.
Description of the illustration theatercompletedform.png
- We'll start by disabling the component for the Capacity menu.
- To create a variable for the Disabled property:
- To set up the action chain:
You can now Preview the page to check your work. Notice that the Capacity field is disabled by default. Select a city, and see that the Capacity field is enabled. Success!
Let's do a quick re-cap of what's happening behind the scenes:
- The user selects a value from the City field.
- The event listener detects that an
On 'value-item'
event has occurred, and fires off theSelectValueItemChangeChain
action chain. - The action chain has one action, which is to assign a value of
false
to thedisableMenuVar
variable. - Because the Disabled property for the Capacity field is controlled by the
disableMenuVar
variable, and that value is nowfalse
, the Capacity field is enabled.