1.5.3 • Published 4 years ago

ember-light-form v1.5.3

Weekly downloads
46
License
MIT
Repository
github
Last release
4 years ago

ember-light-form

This addon provides a flexible framework to manage form states and validations. It allows to use any form control component (e.g. one-way-controls, ember-power-select,...) .

Install

ember install ember-light-form

Example

{{#light-form (changeset post PostValidations) action=(action "createPost") as |f| }}
  {{!-- A basic textfield --}}
  {{f.field 'title' control=f.text}}

  {{f.field 'title'
    control=f.text
    label=(component f.label 'Title:' class='my-custom-class')
  }}

  {{!-- A basic textfield with custom label --}}
  {{f.field 'tags' label=(label 'Keywords') control=f.text}}

  {{!-- A textarea with custom attributes (here required and placeholder) --}}
  {{f.field 'content' control=(component f.textarea required=true placeholder='Your content')}}

  {{!-- A field with a custom component (here ember-power-select) --}}
  {{#f.field 'author' as |field|}}
    {{field.label 'Author:'}}

    {{#power-select options=authors selected=field.value onchange=field.update as |author|}}
      {{author.name}}
    {{/power-select}}
  {{/f.field}}

  <div class="form-actions">
    <button class="action-button action-button__main">
      {{if f.isRunning "Saving..." "Save"}}
    </button>

    {{link-to 'Cancel' 'index' class="cancel-button"}}
  </div>
{{/light-form}}

Built-in controls

Built-in controls rely on ember-one-way-controls.

The available controls are:

Custom controls

You can use any plug-in control and bind them to ember-light-form fields as illustrated below:

{{#f.field 'author' as |field|}}
  {{field.label 'Author:'}}

  {{#power-select options=authors selected=field.value onchange=field.update as |author|}}
    {{author.name}}
  {{/power-select}}
{{/f.field}}

The available attributes are:

  • field.value: the value of the field attribute (here author)
  • field.controlId: the id of the control (match the label for attribute)
  • field.errors: the errors of the field attribute
  • field.update: the action that updates of the field attribute (here author)
1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago