powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 413 forks source link

Allow list editor items to utilize defaultValue #395

Open tnunamak opened 10 years ago

tnunamak commented 10 years ago

When a new list item is added, it's assigned a value of null.

this.addItem(null, true);

https://github.com/powmedia/backbone-forms/blob/master/src/editors/extra/list.js#L17

Because the editor initialization only checks for undefined, the value doesn't get overridden with the defaultValue for that item type:

if (this.value === undefined) this.value = this.defaultValue;

https://github.com/powmedia/backbone-forms/blob/master/src/editor.js#L34

Is there a particular rationale for initializing list items with null values? If not, may I suggest calling addItem with undefined?

iabw commented 10 years ago

Ignore that first pull request.