Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
powmedia committed Oct 12, 2012
1 parent 206951e commit 5bb9ba2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -892,6 +892,8 @@ Writing a custom editor is simple. They must extend from Backbone.Form.editors.B
##Changelog

###master
- Add Form.setValue(key, val) option for arguments (lennym)
- Support ordering years in descending order in Date field (lennym)
- Allow the Number field type to accept decimal values (philfreo)
- Added 'backbone-forms' as a dependency to the AMD wrapper for templates. (seanparmelee)
- Allow use of required validator with checkbox fields (lennym)
Expand Down
16 changes: 13 additions & 3 deletions distribution.amd/backbone-forms.js
Expand Up @@ -328,9 +328,16 @@ var Form = (function() {

/**
* Update field values, referenced by key
* @param {Object} data New values to set
* @param {Object|String} key New values to set, or property to set
* @param val Value to set
*/
setValue: function(data) {
setValue: function(prop, val) {
var data = {};
if (typeof prop === 'string') {
data[prop] = val;
} else {
data = prop;
}
for (var key in data) {
if (_.has(this.fields, key)) {
this.fields[key].setValue(data[key]);
Expand Down Expand Up @@ -1962,7 +1969,10 @@ Form.editors = (function() {
return '<option value="'+month+'">' + value + '</option>';
});

var yearsOptions = _.map(_.range(schema.yearStart, schema.yearEnd + 1), function(year) {
var yearRange = schema.yearStart < schema.yearEnd ?
_.range(schema.yearStart, schema.yearEnd + 1) :
_.range(schema.yearStart, schema.yearEnd - 1, -1);
var yearsOptions = _.map(yearRange, function(year) {
return '<option value="'+year+'">' + year + '</option>';
});

Expand Down
2 changes: 1 addition & 1 deletion distribution.amd/backbone-forms.min.js

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions distribution/backbone-forms.js
Expand Up @@ -341,9 +341,16 @@ var Form = (function() {

/**
* Update field values, referenced by key
* @param {Object} data New values to set
* @param {Object|String} key New values to set, or property to set
* @param val Value to set
*/
setValue: function(data) {
setValue: function(prop, val) {
var data = {};
if (typeof prop === 'string') {
data[prop] = val;
} else {
data = prop;
}
for (var key in data) {
if (_.has(this.fields, key)) {
this.fields[key].setValue(data[key]);
Expand Down Expand Up @@ -1975,7 +1982,10 @@ Form.editors = (function() {
return '<option value="'+month+'">' + value + '</option>';
});

var yearsOptions = _.map(_.range(schema.yearStart, schema.yearEnd + 1), function(year) {
var yearRange = schema.yearStart < schema.yearEnd ?
_.range(schema.yearStart, schema.yearEnd + 1) :
_.range(schema.yearStart, schema.yearEnd - 1, -1);
var yearsOptions = _.map(yearRange, function(year) {
return '<option value="'+year+'">' + year + '</option>';
});

Expand Down
2 changes: 1 addition & 1 deletion distribution/backbone-forms.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/index.html
Expand Up @@ -100,7 +100,7 @@ <h2 id="qunit-userAgent"></h2>
customTemplate: { template: 'customField' },
shorthand: 'Password',
date: { type: 'Date' },
dateTime: { type: 'DateTime', yearStart: 1980, yearEnd: 2000 },
dateTime: { type: 'DateTime', yearStart: 2000, yearEnd: 1980 },

//List
textList: { type: 'List', itemType: 'Text', validators: ['required', 'email'] },
Expand Down

0 comments on commit 5bb9ba2

Please sign in to comment.