Ticket #845 (closed enhancement: fixed)
[patch][cla] FormContainer
| Reported by: | joose@… | Owned by: | dylan |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Widgets | Version: | 0.3 |
| Severity: | normal | Keywords: | FormContainer |
| Cc: | joose@… |
Description
This is FormContainer? widget.
Currently you create forms like this:
myContent='<form name="myForm">";
myContent+='<input type="text" name="name" value="'+obj.name'" />";
myContent+='<input type="text" id="birthday" date="'+dojo.date.format(new Date(obj.birthday),string)+'" />';
myContent+='<input type="button" onClick="myGet()" />';
myContent+='</form>'
function myGet() {
var obj={};
obj["name"]=dojo.byId('myForm').name.value;
obj["birthday"]=dojo.widget.byId('birthday').datePicker.storedDate;
...
}
So it gets very complex and difficult when you have big and lot's of forms.
Now let's see about FormContainer?.
It's purpose is to get/set values to/from object/form. To make it work with dropdowndatepicker, you need apply patch included in ticket #721.
This helps making forms. With this you can easily create "empty" forms like this:
<form dojoType="FormContainer" id="myForm"> <input type="text" name="name" /> <input type="text" name="birthday" dojoType="dropdowndatepicker" /> <input type="button" onClick="myGet()" /> </form>
Then you define object (like, get from the server):
obj.name='Joose Vettenranta'; obj.birthday='11/22/2006';
Then you just command formcontainer:
dojo.widget.byId("myForm").setValues(obj);
When button is pressed, function could be like this:
function myGet() {
var obj=dojo.widget.byId("myForm").getValues();
...
}
So easy!
And now it's very easy to do RAD-style development. Someone creates form, someone creates servers get/set thignies and someone creates stuff together in dojo with formcontainer.