Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create dependencies between parameter values? #391

Open
Eviltux666 opened this issue Mar 15, 2021 · 1 comment
Open

How to create dependencies between parameter values? #391

Eviltux666 opened this issue Mar 15, 2021 · 1 comment
Labels

Comments

@Eviltux666
Copy link

Eviltux666 commented Mar 15, 2021

I would like to define a dependency between two properties, so that certain values of a property are only displayed / can be choosen if another property is set to a certain value.

I know you can use visibleIf to show/hide a property completely, but what I would like to have is a visibleIf for a value.

Example:
properties:
food:
type: string
oneOf:
- description: Pizza
enum:
- pizza
- description: Pasta
enum:
- pasta
extras:
type: string
oneOf:
- description: extra cheese
enum:
- cheese
visibleIf:
food: pizza
- description: mushrooms
enum:
- mushrooms

In this example, I want to show both properties (food, extras), but the extras value "cheese" should only be visible, if "pizza" was selected as food.

How can you do that?

@Eviltux666 Eviltux666 changed the title #question How to create dependencies between parameter values? Mar 15, 2021
@daniele-pecora
Copy link
Collaborator

Unfortunately enum contained in oneOf of a visibleIf condition will not be processed for visibility.

But this could be handelt inside the validator.
Here a quick and dirty example that shows one way of how this could be achieved:
https://stackblitz.com/edit/ngx-schema-form-template-visibleif-enums?file=src%2Fapp%2Fmyform%2Fschema-form-validators.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants