0

我使用了 ["*"] 的 formOptions 以及 []。每当我在字段中输入有效数据时,输入旁边都会显示文本“(成功)”。我该如何关闭它?我在任何示例中都没有看到这一点,也无法弄清楚我在做什么不同。

4

2 回答 2

1

它是可配置的,您可以全局禁用成功消息:

https://github.com/json-schema-form/angular-schema-form/blob/development/docs/index.md

原始对象 {errors ,success}:设置当表单字段为 $pristine 时错误和成功状态是否应该可见。默认为 {errors: true, success: true}

你应该设置成功:假

也可以在本地禁用成功消息作为表单字段的选项:

-> disableSuccessState: true

标准选项:

{
  key: "address.street",      // The dot notatin to the attribute on the model
  type: "text",               // Type of field
  title: "Street",            // Title of field, taken from schema if available
  notitle: false,             // Set to true to hide title
  description: "Street name", // A description, taken from schema if available, can be HTML
  validationMessage: "Oh noes, please write a proper address",  // A custom validation error message
  onChange: "valueChanged(form.key,modelValue)", // onChange event handler, expression or function
  feedback: false,             // Inline feedback icons
  disableSuccessState: false,  // Set true to NOT apply 'has-success' class to a field that was validated successfully
  disableErrorState: false,    // Set true to NOT apply 'has-error' class to a field that failed validation
  placeholder: "Input...",     // placeholder on inputs and textarea
  ngModelOptions: { ... },     // Passed along to ng-model-options
  readonly: true,              // Same effect as readOnly in schema. Put on a fieldset or array
                               // and their items will inherit it.
  htmlClass: "street foobar",  // CSS Class(es) to be added to the container div
  fieldHtmlClass: "street"     // CSS Class(es) to be added to field input (or similar)
  labelHtmlClass: "street"     // CSS Class(es) to be added to the label of the field (or similar)
  copyValueTo: ["address.street"],     // Copy values to these schema keys.
  condition: "person.age < 18" // Show or hide field depending on an angular expression
  destroyStrategy: "remove"    // One of "null", "empty" , "remove", or 'retain'. Changes model on $destroy event. default is "remove".
}

我希望它有所帮助。

于 2016-04-05T23:54:21.927 回答
0

我想出的唯一解决方案是确保将以下样式添加到页面中。这就是它在 Angular Schema Form 示例中的工作方式。您可以查看以下 plunker - http://plnkr.co/edit/X90gRqnRMNbjWouLJJSu

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

更改该类的名称,每当您在文本框中键入时,您都会看到“(成功)”。我认为这非常hacky,但这是我找到的唯一解决方案。在我的场景中,我需要一个全局解决方案。我无法为每个键创建表单选项,因为模式是用户生成的。

如果有人可以提供一个更清洁的解决方案,我很乐意看到。请不要只是发布一个想法,而是在 Plunker 中尝试并证明您的想法有效。我尝试了很多想法,上面的样式是唯一可行的。

于 2016-04-27T22:47:58.497 回答