Skip to content

Commit

Permalink
Improvements to field
Browse files Browse the repository at this point in the history
  • Loading branch information
surdu committed Sep 26, 2016
1 parent 79681e7 commit cdd2cba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions fields/baseField.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ BaseField.prototype = {
var fieldInfo = clone(defaultFieldInfo);
extend(fieldInfo, userFieldInfo);

this.fieldInfo = fieldInfo;

this.type = fieldInfo.type;
this.label = fieldInfo.label || nameToLabel(fieldInfo.name);
this.name = fieldInfo.name;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formless",
"version": "0.1.3",
"version": "0.1.4",
"description": "Form handling solution for node.js",
"main": "formless.js",
"scripts": {
Expand Down
16 changes: 7 additions & 9 deletions parsers/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ MongooseParser.prototype = {
continue;
}

var fieldType = formlessOptions.type || typeMappings[mongoField.instance];
// inherit all options from the `formless` property
var field = JSON.parse(JSON.stringify(formlessOptions));

if (!fieldType) {
field.type = formlessOptions.type || typeMappings[mongoField.instance];

if (!field.type) {
throw Error("Can't parse field " + model.modelName + "." + fieldName + " of type " + mongoField.instance);
}

var field = {
type: fieldType,
name: fieldName,
label: formlessOptions.label || undefined,
required: mongoField.isRequired,
placeholder: formlessOptions.placeholder || ""
};
field.name = fieldName;
field.required = mongoField.isRequired;

fields.push(field);
}
Expand Down

0 comments on commit cdd2cba

Please sign in to comment.