Angular Schema Form - 如何摆脱(成功)文本

时间:2016-04-05 23:24:27

标签: angular-schema-form

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

2 个答案:

答案 0 :(得分:1)

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

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

  

pristine Object {errors,success}:设置错误和成功状态   当表单字段为$ pristine时应该是可见的。默认是{errors:   是的,成功:真实}

你应该设置成功:false

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

-> 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".
}

我希望它有所帮助。

答案 1 :(得分: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;
}

更改该课程的名称,您将看到&#34;(成功)&#34;每当你输入文本框时都会回来。我认为这非常hacky,但它是我发现的唯一解决方案。在我的场景中,我需要一个全局解决方案。我无法为每个密钥创建表单选项,因为模式是用户生成的。

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