I am considering modifying FormKit to make it easier to define your form in the beginning. Consider, when you look at a form in XHTML, you see the structure of the form. You might a <form> containing set of checkboxes inside the form, a pulldown tab, and a bunch of choices inside that, etc. You can easily see the structure of the form elements. This is due I think to the indenting and also to name of each tag being the first word. As your eye scans the file, you can see the first word of each line and then can ignore the rest of the line unless you want the details. In other words, the structure is easy to discern from a quick glance. Compare that to how you construct a Form() right now.
Here's an example of a form with some checkboxes, a text field, and a validator, and a button. The way it works now is:
# get a simple validator set up notEmpty = Validators.NotEmpty()
f = self.form = Form.Form( )
f.addField( CheckboxSet('survey', label="Check all that apply") )
surveyChoices = ChoiceList()
self.form.survey.setChoices( surveyChoices )
surveyChoices.addChoice('Windows','I use MS Windows')
surveyChoices.addChoice('MacOS','I use MacOS')
surveyChoices.addChoice('Unix','I use a Unix-like operating system (that isnt MacOS)')
f.addField( Fields.TextField('textBox',[notEmpty]) )
f.addField( Fields.WebKitSubmitButton(name="osBtn",label="Make it So") )
And I'm thinking just of changing the __init__() methods so you could write something like this instead:
# get a simple validator set up notEmpty = Validators.NotEmpty()
self.form = Form.Form( add=(
CheckboxSet('survey', label="Check all that apply",
ChoiceList( add=(
Choice('Windows', 'I use MS Windows'),
Choice( 'MacOS', 'I use MacOS' ),
Choice('Unix', 'I use a Unix-like operating system (that isnt MacOS)' )
) ) #ChoiceList
), # CheckboxSet
TextField('textBox', [notEmpty] ),
WebKitSubmitButton(name="osBtn",label="Make it So")
) )
Here each constructor includes as the last element, an optional 'add' parameter. In it, you can pass a tuple of sub-elements that are added to the form. In this way I want to eliminate a lot of the wordiness of the all the addXxx() methods, and try to let the structure of my form show through. The indentation shows the structure, and the first word of each line shows what element is there.
Does anybody have any comments or suggestions before I try this out?
-winston
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ Webware-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-devel