如何在Form.io

时间:2019-02-11 16:09:14

标签: angular forms formio

我正在为Formio隐藏我的表单的按钮组件而苦苦挣扎。我需要在表单中隐藏提交按钮。请帮忙。预先感谢

在我的代码中可以看到我认为唯一可行的东西。我也尝试将它作为数组放入我的renderOptions中。什么都没有。

HTML:

<div>   
    <formio 
        [form]="structuredForm" 
        [submission]='{"data":formSubmission }'
        [renderOptions]="formioRenderOptions"
        hide-components="['submit', 'submit5']"> 
    </formio> 
</div>

我的formioRenderOption是否需要在此处设置隐藏的按钮?

this.formioRenderOptions = {
  noAlerts: true,
  language: this.translateService.currentLang.replace('_', '-')
  i18n: '',
  readOnly: true,
};

我的带有2个按钮的Formio JSON文件:


        {
            "label": "save",
            "action": "event",
            "showValidations": false,
            "event": "saveDraftEvent",
            "theme": "primary",
            "shortcut": "",
            "disableOnInvalid": true,
            "mask": false,
            "tableView": true,
            "alwaysEnabled": false,
            "type": "button",
            "key": "submit4",
            "input": true,
            "conditional": {
                "show": "",
                "when": "",
                "json": ""
            },
            "customConditional": "",
            "properties": {},
            "tags": [],
            "logic": [],
            "defaultValue": true
        },
        {
            "label": "next",
            "action": "event",
            "showValidations": false,
            "event": "submitApplicationEvent",
            "theme": "primary",
            "shortcut": "",
            "disableOnInvalid": true,
            "mask": false,
            "tableView": true,
            "alwaysEnabled": false,
            "type": "button",
            "key": "submit5",
            "input": true,
            "conditional": {
                "show": "",
                "when": "",
                "json": ""
            },

现在我的表单为readOnly,但是按钮仍然可见而不是隐藏。

2 个答案:

答案 0 :(得分:0)

您可以将不想显示的组件的hidden属性设置为true。

"hidden": true

如果要基于表单中其他组件的值有条件地显示或隐藏组件,则可以使用组件对象的条件属性。

"conditional": {
    "show": "",
    "when": "",
    "json": ""
},

这里,“ show”属性将保留“ true”或“ false”,“ when”属性将保留条件,而“ json”属性将保留任何其他json验证代码。

我希望这能解决您的问题。

答案 1 :(得分:0)

您可以将hidden属性设置为true,如此处已回答!或者,如果您希望在任何特定时间加载表单后将属性设置为隐藏,则可以

controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
         $scope.component.type='hidden';

    }],

,这会将属性类型更改为

  

隐藏的表单域类型