Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 0e3622faf3d84c6a1fa24ecbb94856cd41eb9b8e 1 parent 0c4c54e
Phil Freo philfreo authored

Showing 2 changed files with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. +5 0 src/field.js
  2. +10 0 test/field.js
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').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 0e3622f

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