Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ cache:

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
# - EMBER_TRY_SCENARIO=ember-release
# - EMBER_TRY_SCENARIO=ember-beta
# - EMBER_TRY_SCENARIO=ember-canary

matrix:
fast_finish: true
Expand Down
2 changes: 2 additions & 0 deletions addon/components/form-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var FormFormComponent = Ember.Component.extend(WrapperMixin, {
classNameBindings: ['wrapperConfig.formClass'],
novalidate: 'novalidate',
wrapper: 'default',
layoutName: Ember.computed.oneWay('wrapperConfig.formTemplate'),


init: function() {
this._super(...arguments);
Expand Down
15 changes: 15 additions & 0 deletions addon/components/internal-input-for.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import WrapperMixin from 'ember-easy-form/wrapper-mixin';
import {humanize} from 'ember-easy-form/utilities';
import {assign} from 'ember-easy-form/utilities';

const PropertyNameNotDefinedMessage = 'Please, define the property name. ' +
'You probably forgot to quote the property name in some `input-for` component.';
Expand Down Expand Up @@ -88,6 +89,20 @@ var FormInputComponent = Ember.Component.extend(WrapperMixin, {
this.set('hasFocusedOut', true);
this.showValidationError();
},
inputOptions: Ember.computed('savedInputOptions', 'attrs', function() {
var inputOptions = this.get('savedInputOptions');
if (!inputOptions) {
// Move all values to the `inputOptions` hash, except the ones we use in the `internal-input-for`
inputOptions = assign({}, this.get('attrs'));
for(let i=0; i<knownProperties.length; i++) {
const key = knownProperties[i];
if (inputOptions.hasOwnProperty(key)) {
delete inputOptions[key];
}
}
}
return inputOptions;
}),
showValidationError: function() {
if (this.get('hasFocusedOut')) {
var property = this.get('propertyName');
Expand Down
1 change: 1 addition & 0 deletions addon/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
hintClass: 'hint',
labelClass: '',
submitClass: '',
formTemplate: 'components/easy-form/form',
inputTemplate: 'components/easy-form/input-for',
errorTemplate: 'components/easy-form/error-field',
labelTemplate: 'components/easy-form/label-field',
Expand Down
2 changes: 1 addition & 1 deletion addon/keywords/input-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
}
}

customHash.inputOptions = inputOptions;
customHash.savedInputOptions = inputOptions;
return assign({}, state, { customHash: customHash });
},

Expand Down
1 change: 1 addition & 0 deletions app/templates/components/easy-form/form.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield (hash input=(component "internal-input-for"))}}
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-easy-form",
"dependencies": {
"ember": "1.13.11",
"ember": "components/ember#canary",
"ember-cli-shims": "0.0.6",
"ember-cli-test-loader": "0.2.1",
"ember-load-initializers": "0.1.7",
Expand All @@ -11,5 +11,8 @@
"jquery": "^1.11.3",
"loader.js": "ember-cli/loader.js#3.4.0",
"qunit": "~1.20.0"
},
"resolutions": {
"ember": "canary"
}
}
8 changes: 5 additions & 3 deletions tests/dummy/app/templates/person.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<h2>Person form</h2>
<div id="teste">
{{#form-for model}}
{{input-for "firstName"}}
{{input-for "lastName"}}

{{#form-for model as |f|}}
{{f.input "firstName"}}
{{f.input "lastName"}}
<input type="submit">
{{/form-for}}


<p class="bound-values">
First name: <span class="first-name">{{model.firstName}}</span><br>
Last name: <span class="last-name">{{model.lastName}}</span><br>
Expand Down