Skip to content
This repository has been archived by the owner on Sep 28, 2018. It is now read-only.

Commit

Permalink
add text_area support
Browse files Browse the repository at this point in the history
  • Loading branch information
yssk22 committed Dec 3, 2009
1 parent 5cf29a0 commit 205b95f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/form.js
Expand Up @@ -45,6 +45,23 @@ Crayon.Form = {
return tag("input",html_opt);
},

/**
* Returns an textarea tag tailored for accessing a specified attribute.
* @param {Object} doc JSON document to bind.
* @param {String} path JSON member path seperated by "-".
* @param [Object] options tag attribute options.
*/
text_area : function(doc, path, options){
var val = Crayon.Form._getValueFromPath(doc, path);
// html options
var html_opt = Crayon.extend({
id : path,
name: path
}, options);
html_opt["type"] = "text";
return content_tag("textarea", val || "", html_opt);
},

/**
* Returns a set of select tags for date selection.
* @param {String} date the default selected value.
Expand Down
17 changes: 17 additions & 0 deletions spec/spec.form.js
Expand Up @@ -67,6 +67,23 @@ JSpec.describe("form", function(){
});
});

describe("text_area", function(){
it("should return area tag bound to doc.a.b.c", function(){
var doc = {
a: {
b: {
c: "foo"
}
}
};
var result = text_area(doc, "a-b-c");
expect(result).should(match, /name="a-b-c"/);
expect(result).should(match, /id="a-b-c"/);
expect(result).should(match, /\>foo\<\/textarea\>/);
});
});


describe("date_select", function(){
it("should return select tags bound to doc.a.b.c", function(){
var doc = {
Expand Down

0 comments on commit 205b95f

Please sign in to comment.