Skip to content
This repository
Browse code

Merge pull request #155 from philfreo/master

Don't render <label> if schema title === false
  • Loading branch information...
commit ef5ef69a95457c785e28d128d7c2a670039a935a 2 parents bcc6a4e + 528d66f
Phil Freo philfreo authored

Showing 3 changed files with 16 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  README.md
  2. +5 0 src/field.js
  3. +10 0 test/field.js
1  README.md
Source Rendered
@@ -892,6 +892,7 @@ Writing a custom editor is simple. They must extend from Backbone.Form.editors.B
892 892 ##Changelog
893 893
894 894 ###master
  895 +- Don't show <label> if schema title===false (philfreo)
895 896 - Fix change event on radio editor (DominicBoettger)
896 897 - Fix model errors not being return by validate() (mutewinter)
897 898 - Setting value with setValue only from form.schema (okhomenko)
5 src/field.js
@@ -102,6 +102,11 @@ Form.Field = (function() {
102 102
103 103 //Create the element
104 104 var $field = $(templates[schema.template](this.renderingContext(schema, editor)));
  105 +
  106 + //Remove <label> if it's not wanted
  107 + if (schema.title === false) {
  108 + $field.find('label[for="'+editor.id+'"]').first().remove();
  109 + }
105 110
106 111 //Render editor
107 112 $field.find('.bbf-tmp-editor').replaceWith(editor.render().el);
10 test/field.js
@@ -70,6 +70,16 @@ test("'schema.title' option - Defaults to formatted version of 'key' option", fu
70 70 equal($('label', field.el).html(), 'Camel Cased Title');
71 71 });
72 72
  73 +test("'schema.title' false option - does not render a <label>", function() {
  74 + var field = new Field({
  75 + value: 'test',
  76 + key: 'title',
  77 + schema: { title: false }
  78 + }).render();
  79 +
  80 + equal($('label', field.el).length, 0);
  81 +});
  82 +
73 83 test("'schema.help' option - Specifies help text", function() {
74 84 var field = new Field({
75 85 key: 'title',

0 comments on commit ef5ef69

Please sign in to comment.
Something went wrong with that request. Please try again.