ng-dynamic-forms icon indicating copy to clipboard operation
ng-dynamic-forms copied to clipboard

Relation, when value not equal to something?

Open PraetorianXX opened this issue 7 years ago • 7 comments

I'm submitting a


[ ] Bug / Regression
[ ] Feature Request / Proposal
[x] Question

I'm using


NG Dynamic Forms Version: 5.4.7

[ ] Basic UI
[ ] Bootstrap UI  
[ ] Foundation UI
[ ] Ionic UI
[ ] Kendo UI
[ ] Material  
[x] NG Bootstrap
[ ] Prime NG

Description

I'm trying to use related form controls and disable a question when a previous question is not equal to a particular value. In the example below I can disable the second question when the first question is equal to "test" and that works as expected, but I would like to disable the second question when the first question is not equal to a particular value


new DynamicFormGroupModel({
                id: 'formGroup',
                group: [
                    new DynamicInputModel(
                        {
                            id: 'firstQ',
                            label: 'First Question',
                            maxLength: 50,
                        },
                    ),
                    new DynamicInputModel(
                        {
                            id: 'secondQ',
                            label: 'Second Question',
                            maxLength: 50,
                            relation: [
                                {
                                    action: 'DISABLE',
                                    when: [
                                        {
                                            id: 'firstQ',
                                            value: 'test',
                                        }
                                    ]
                                }
                            ]
                        }
                    )
                ]
            })

Is it possible to make that value test a negative test (value !== something)?

PraetorianXX avatar May 24 '18 11:05 PraetorianXX

@udos86 ive got a sample I can give you which adds an operator field for these methods which allow multiple types of operators I.e. == === != >= > <= <

bevbomb avatar Jun 07 '18 13:06 bevbomb

@bevbomb it would be awesome if you could!

PraetorianXX avatar Jun 08 '18 09:06 PraetorianXX

@bevbomb it would be awesome if you could!

Hello, could you share these samples?

AndreaRossiGit avatar Jul 28 '20 07:07 AndreaRossiGit

@AndreaRossiGit they have made some major changes to this package since I last worked on it and I'm afraid that my original work for handling relations doesn't work with the latest versions of this package. I can still, however, give you a sample of how I have been handling comparisons using operators. https://gist.github.com/bevbomb/1bbed68752e97d16d5146b77e314f768

bevbomb avatar Jul 28 '20 07:07 bevbomb

@bevbomb how would i use this operator in my json to see if value is NOT null

drkhannah avatar Aug 12 '20 15:08 drkhannah

@bevbomb how would i use this operator in my json to see if value is NOT null

{
  "key": "someField",
  "label": "Some Field",
  "relation": [{
    "action": "SHOW",
    "connective": "AND",
    "when": [{
      "id": "anotherField",
      "operator": "!=",
      "value": "null"
    }]
  }]
}

bevbomb avatar Aug 12 '20 23:08 bevbomb

thank you, how would i go about adding your gist code to my project?

drkhannah avatar Aug 13 '20 13:08 drkhannah