Skip to content

Commit

Permalink
Add empty formatValueToField & formatValueToModel. Fix #308 #276
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Oct 9, 2017
1 parent 5cdc4ce commit 3353860
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/fields/abstractField.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ export default {
else if (this.model && this.schema.model)
val = objGet(this.model, this.schema.model);

if (isFunction(this.formatValueToField))
val = this.formatValueToField(val);

return val;
return this.formatValueToField(val);
},

set(newValue) {
let oldValue = this.value;

if (isFunction(this.formatValueToModel))
newValue = this.formatValueToModel(newValue);
newValue = this.formatValueToModel(newValue);

let changed = false;
if (isFunction(this.schema.set)) {
Expand Down Expand Up @@ -167,7 +163,14 @@ export default {
getFieldID(schema) {
const idPrefix = this.formOptions && this.formOptions.fieldIdPrefix ? this.formOptions.fieldIdPrefix : "";
return slugifyFormID(schema, idPrefix);
}
},

formatValueToField(value) {
return value;
},

formatValueToModel(value) {
return value;
}
}
};

0 comments on commit 3353860

Please sign in to comment.