Skip to content

Commit

Permalink
render label correctly if a custom id is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
rburns authored and Caolan McMahon committed Jan 25, 2011
1 parent 9711995 commit 61dd58b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/render.js
Expand Up @@ -15,7 +15,7 @@ var wrapWith = function(tag){
}
else {
html += field.errorHTML() +
field.labelHTML(name) +
field.labelHTML(name, field.id) +
field.widget.toHTML(name, field);
}
return html + '</' + tag + '>';
Expand Down
15 changes: 15 additions & 0 deletions test/test-render.js
Expand Up @@ -108,6 +108,21 @@ var testWrap = function(tag){
test.done();
};

exports[tag + ' label custom id'] = function(test){
var f = forms.create({
fieldname: forms.fields.string({
id: 'custom-id'
})
});
test.equals(
f.toHTML(forms.render[tag]),
'<' + tag + ' class="field">' +
'<label for="custom-id">Fieldname</label>' +
'<input type="text" name="fieldname" id="custom-id" />' +
'</' + tag + '>'
);
test.done();
};
};

testWrap('div');
Expand Down

0 comments on commit 61dd58b

Please sign in to comment.