Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric O'Connell committed Dec 17, 2012
2 parents 25d20ad + fa9b509 commit 878db37
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -892,6 +892,7 @@ Writing a custom editor is simple. They must extend from Backbone.Form.editors.B
##Changelog

###master
- Don't show <label> if schema title===false (philfreo)
- Fix change event on radio editor (DominicBoettger)
- Fix model errors not being return by validate() (mutewinter)
- Setting value with setValue only from form.schema (okhomenko)
Expand Down
5 changes: 5 additions & 0 deletions distribution.amd/backbone-forms.js
Expand Up @@ -825,6 +825,11 @@ Form.Field = (function() {

//Create the element
var $field = $(templates[schema.template](this.renderingContext(schema, editor)));

//Remove <label> if it's not wanted
if (schema.title === false) {
$field.find('label[for="'+editor.id+'"]').first().remove();
}

//Render editor
$field.find('.bbf-tmp-editor').replaceWith(editor.render().el);
Expand Down
2 changes: 1 addition & 1 deletion distribution.amd/backbone-forms.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions distribution/backbone-forms.js
Expand Up @@ -838,6 +838,11 @@ Form.Field = (function() {

//Create the element
var $field = $(templates[schema.template](this.renderingContext(schema, editor)));

//Remove <label> if it's not wanted
if (schema.title === false) {
$field.find('label[for="'+editor.id+'"]').first().remove();
}

//Render editor
$field.find('.bbf-tmp-editor').replaceWith(editor.render().el);
Expand Down
2 changes: 1 addition & 1 deletion distribution/backbone-forms.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/field.js
Expand Up @@ -102,6 +102,11 @@ Form.Field = (function() {

//Create the element
var $field = $(templates[schema.template](this.renderingContext(schema, editor)));

//Remove <label> if it's not wanted
if (schema.title === false) {
$field.find('label[for="'+editor.id+'"]').first().remove();
}

//Render editor
$field.find('.bbf-tmp-editor').replaceWith(editor.render().el);
Expand Down
10 changes: 10 additions & 0 deletions test/field.js
Expand Up @@ -70,6 +70,16 @@ test("'schema.title' option - Defaults to formatted version of 'key' option", fu
equal($('label', field.el).html(), 'Camel Cased Title');
});

test("'schema.title' false option - does not render a <label>", function() {
var field = new Field({
value: 'test',
key: 'title',
schema: { title: false }
}).render();

equal($('label', field.el).length, 0);
});

test("'schema.help' option - Specifies help text", function() {
var field = new Field({
key: 'title',
Expand Down

0 comments on commit 878db37

Please sign in to comment.