Don't render <label> if schema title === false #155

Merged
merged 3 commits into from Dec 3, 2012
View
1 README.md
@@ -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)
View
5 src/field.js
@@ -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);
View
10 test/field.js
@@ -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',