API Docs for:
Show:

Ember.EasyForm.Config

Summary

Ember.EasyForm配置项,可以向Config内注册自定义组件,注册自定义模板等

Item Index

Methods

Properties

Methods

registerWrapper

Syntax

registerWrapper

()

Summary

向Ember.EasyForm Wrapper中注册一个Wraper

Ember.EasyForm.Config.registerWrapper('my-wrapper', {
 formClass: 'my-form',
 errorClass: 'my-error',
 hintClass: 'my-hint',
 labelClass: 'my-label'
});
{{#form-for model wrapper="my-wrapper"}}
  {{input firstName}}
  {{input lastName}}
{{/form-for}}

编译结果为

  <form class="my-form">
    <div class="input string">
      <label for="ember1">First name</label>
      <input id="ember1" type="text"/>
      <span class="error"></span>
    </div>
    <div class="input string">
      <label for="ember2" class="my-label">Last name</label>
      <input id="ember2" type="text"/>
      <span class="error my-error"></span>
    </div>
  </form>

Ember.EasyForm也支持向Wrapper中注册模板

    Ember.EasyForm.Config.registerWrapper('twitter-bootstrap', {
     // Define the custom template
     inputTemplate: 'bootstrap-input',

     // Define a custom config used by the template
     controlsWrapperClass: 'controls',

     // Define the classes for the form, label, error...
     formClass: 'form-horizontal',
     fieldErrorClass: 'error',
     errorClass: 'help-inline',
     hintClass: 'help-block',
     labelClass: 'control-label',
     inputClass: 'control-group'
   });

bootstrap-input模板

  {{label-field propertyBinding="view.property" textBinding="view.label"}}
      <div class="{{unbound view.wrapperConfig.controlsWrapperClass}}">
  {{partial "easyForm/inputControls"}}
</div>

Properties

Wrapper

Syntax

Wrapper

Unknown

Summary

Wrapper

Wrapper定义了EasyForm渲染视图时的样式与模板

可定制项包括:

  • fieldErrorClass - class used by the field containing errors
  • formClass - class used by the form
  • inputClass - class used by the div containing all elements of the input (label, input, error and hint)
  • errorClass - class used by the error message
  • hintClass - class used by the hint message
  • labelClass - class used by the label
  • inputTemplate - template used by {{input}}
  • labelTemplate - template used by {{label-field}}
  • errorTemplate - template used by {{error-field}}
  • hintTemplate - template used by {{hint-field}}

默认Wrapper配置情况

  • formClass - "" (empty)
  • fieldErrorClass - "fieldWithErrors"
  • inputClass - "input"
  • errorClass - "error"
  • hintClass - "hint"
  • labelClass - "" (empty)
  • inputTemplate - "easyForm/input"
  • labelTemplate - "easyForm/label"
  • errorTemplate - "easyForm/error"
  • hintTemplate - "easyForm/hint"