0

我是角度形式的新手

我想使用 formly 为以下场景构建表单:

  1. 有三个兄弟元素
  2. 其中两个元素取决于一个兄弟元素的值,即单选按钮组。即我想根据收件人查询选项隐藏或显示基本高级表单
  3. 我正在使用 JSON 文件来存储架构,因此无法将隐藏表达式直接写入架构。

我尝试使用 Extension 来隐藏表达式,但我发现在 Extension 中模型中可用的数据仅限于编写隐藏表达式的元素及其子元素,并且不包含其父元素的数据。由于父级的数据不可用,我无法检查单选按钮的值,也无法决定是否隐藏元素。

以下是 JSON 模式:

{
    key: 'Recipients',
    fieldGroup: [{
            key: 'recipientQueryOption',
            type: 'radio',
            templateOptions: {
                required: true,
                options: [{
                        value: 'queryBuilder',
                        label: 'queryBuilder'
                    },
                    {
                        value: 'queryEditor',
                        label: 'queryEditor'
                    },
                ],
            },
            defaultValue: 'queryBuilder'
        },
        {
            key: "basic",
            fieldGroup: [{
                key: 'recipients',
                type: 'chips',
                templateOptions: {
                    label: 'Recipients',
                    placeholder: 'add recipients...',
                    required: true,
                }
            }],
            hideExpression: "hide_expression"
        },
        {
            key: "advance",
            fieldGroup: [{
                    key: 'recipients',
                    type: 'textarea',
                    templateOptions: {
                        label: 'Recipients',
                        placeholder: 'Enter Query',
                        required: true,
                    }
                },
                {
                    template: '<b>Note:</b> No validation is done on the queries submitted from the Query Editor tab.',
                }
            ]
        }
    ]
}
4

0 回答 0