Skip to content

DynamicFormControlCondition - improvement on DynamicFormRelationService matchesCondition #1182

@Wchua

Description

@Wchua

I'm submitting a


[ ] Bug / Regression
[X] Feature Request / Proposal

I'm using


NG Dynamic Forms Version: `18.0.0`

[ ] Basic UI
[ ] Bootstrap UI  
[ ] Foundation UI
[ ] Ionic UI
[ ] Material  
[ ] NG Bootstrap
[X ] Prime NG

Description

Use case

I want to show/hide some fields based on the value of other fields (selectModel) which has custom object as options/values.

Problem

The DynamicFormRelationService does the relations match on the matchesCondition function using strict equality which when comparing objects returns false.

Proposed Solution

Add an optional function called matched to the DynamicFormControlCondition which, in case it is defined, it will take precedence over the current value property.

export interface DynamicFormControlCondition {
    id?: string;
    rootPath?: string;
    status?: string;
    value?: any;
    matched?: (relatedFormControlValue: any) => boolean; // Has precedence over value
}

This way we can match the value correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions