udos86 / ng-dynamic-forms

Rapid form development library for Angular
ISC License
1.32k stars 369 forks source link

Relation not working if multiple = true #1038

Open shure77 opened 5 years ago

shure77 commented 5 years ago

I'm submitting a


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

I'm using


NG Dynamic Forms Version: `X.Y.Z`

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

Description

Relation is not working if I want to make my INPUT dependent to a SELECT with multiple = true:

Example:

{ "id": "lenker_fuehrerscheinKlassen", "type": "SELECT", "placeholder": "Führerscheinklassen", "multiple": true, "required": true, "validators": { "required": null }, "errorMessages": { "required": "{{ placeholder }} ist ein Pflichtfeld." }, "options": [ { "label": "AM", "value": "am" }, { "label": "A1", "value": "a1" }, { "label": "A2", "value": "a2" } ] }, { "id": "lenker_fuehrerscheinComment", "type": "INPUT", "label": "Kommentar", "relations": [ { "match": "VISIBLE", "when": [ { "id": "lenker_fuehrerscheinKlassen", "value": "am" } ] } ] }

mischkl commented 5 years ago

I also have this problem - relations only work for simple values, not if one of the values in a multiple-select matches. And unfortunately it doesn't really help to try to write my own matcher, because all I get is "isMatch" true or false - I can't modify the logic for the test itself.

udos86 commented 4 years ago

@shure77 @mischkl

I'll have a look at this

AndreaRossiGit commented 4 years ago

@shure77 @mischkl

I'll have a look at this

Hello, did you figure out how to solve this?

shure77 commented 4 years ago

@AndreaRossiGit Hey, I am not sure but I think putting the controls in a group did the trick:

group: [ { id: 'fuehrerscheinKlassen', type: TYPE_CHIP_CHOICE, placeholder: 'Führerscheinklassen', required: true, errorMessages: { required: '{{ placeholder }} ist ein Pflichtfeld.', }, options: [ { label: 'AM', value: 'AM', }, { label: 'A1', value: 'A1', }, { label: 'A2', value: 'A2', }, { label: 'A', value: 'A', }, { label: 'B1', value: 'B1', }, { label: 'B', value: 'B', }, { label: 'C1', value: 'C1', }, { label: 'C', value: 'C', }, { label: 'D1', value: 'D1', }, { label: 'D', value: 'D', }, { label: 'BE', value: 'BE', }, { label: 'C1E', value: 'C1E', }, { label: 'CE', value: 'CE', }, { label: 'D1E', value: 'D1E', }, { label: 'DE', value: 'DE', }, { label: 'F', value: 'F', }, ], }, { id: 'fuehrerscheinRueckseite', type: TYPE_CUSTOM_FILE_UPLOAD, labelTooltip: 'Führerscheinrückseite für Klasse "AM" hinzufügen', relations: [ { match: MATCH_SELECT_VISIBLE, when: [ { id: 'fuehrerscheinKlassen', value: ['AM'], }, ], }, ]

olayda commented 2 years ago

hello, did anyone find a solution for this? @shure77's solution didn't work for me