Skip to content

Commit

Permalink
Merge pull request #155 from philfreo/master
Browse files Browse the repository at this point in the history
Don't render <label> if schema title === false
  • Loading branch information
philfreo committed Dec 3, 2012
2 parents bcc6a4e + 528d66f commit ef5ef69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 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 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 ef5ef69

Please sign in to comment.