Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 3 commits into from

1 participant

Phil Freo
Phil Freo
Collaborator

Fixes #142

@powmedia let me know if you see any issues with this

The alternative would be to do a conditional in the template itself, but depends more on a specific templating language.

Phil Freo philfreo merged commit ef5ef69 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2012
  1. Phil Freo
  2. Phil Freo
Commits on Nov 15, 2012
  1. Phil Freo

    Changelog

    philfreo authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 0 deletions.
  1. +1 −0  README.md
  2. +5 −0 src/field.js
  3. +10 −0 test/field.js
1  README.md
View
@@ -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)
5 src/field.js
View
@@ -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);
10 test/field.js
View
@@ -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',
Something went wrong with that request. Please try again.