I have 2 Formly forms in my app.
I need to hide a field of one form, due the value of a field in the another one.
Formly documentation gives this option (https://formly.dev/examples/field-options/hide-fields):
hideExpression: '!model.name'
But I need something like: hideExpression: '!anotherModel.name'
export class AppComponent {
form = new FormGroup({});
model: any = {};
options: FormlyFormOptions = {};
fields: FormlyFieldConfig[] = [
{
key: 'iLikeTwix',
type: 'checkbox',
templateOptions: {
label: 'I like twix',
},
hideExpression: '!model2.name',
},
];
form2 = new FormGroup({});
model2: any = {};
options2: FormlyFormOptions = {};
fields2: FormlyFieldConfig[] = [
{
key: 'name',
type: 'input',
templateOptions: {
label: 'Name'
},
}
];
}
Notice the line: hideExpression: '!model2.name'
, it is what I want to do.
Can I do it?
Thanks.
model
part is static, but I do not see your issue here. Please produce a minimal reproducible example reproducing your issue.