Author: dbinger Date: 2005-04-05 06:26:03 -0400 (Tue, 05 Apr 2005) New Revision: 26469 Modified: trunk/quixote/form/__init__.py trunk/quixote/form/widget.py Log: nas: Allow the label for the 'Add row' button to be specified. The 'Add' part may not always make sense. Also, add WidgetDict to widget.__init__ and fix some comments. Changed: quixote/form/__init__.py quixote/form/widget.py Modified: trunk/quixote/form/__init__.py =================================================================== --- trunk/quixote/form/__init__.py 2005-04-01 22:27:38 UTC (rev 26468) +++ trunk/quixote/form/__init__.py 2005-04-05 10:26:03 UTC (rev 26469) @@ -15,4 +15,4 @@ SingleSelectWidget, SelectWidget, OptionSelectWidget, \ MultipleSelectWidget, SubmitWidget, HiddenWidget, \ FloatWidget, IntWidget, subname, WidgetValueError, CompositeWidget, \ - WidgetList + WidgetList, WidgetDict Modified: trunk/quixote/form/widget.py =================================================================== --- trunk/quixote/form/widget.py 2005-04-01 22:27:38 UTC (rev 26468) +++ trunk/quixote/form/widget.py 2005-04-05 10:26:03 UTC (rev 26469) @@ -786,7 +786,7 @@ def __init__(self, name, value=None, element_type=StringWidget, element_kwargs={}, - element_name="row", **kwargs): + add_element_label="Add row", **kwargs): assert value is None or type(value) is list, ( "value '%s' not a list: got %r" % (name, value)) assert issubclass(element_type, Widget), ( @@ -822,7 +822,7 @@ add_element() # Add submit to add more element widgets - self.add(SubmitWidget, 'add_element', value='Add %s' % element_name) + self.add(SubmitWidget, 'add_element', value=add_element_label) if self.get('add_element'): add_element() num_added += 1 @@ -861,8 +861,8 @@ class WidgetDict(CompositeWidget): """A variable length dict of widgets. There is only one - title and hint but each element of the list can have its own - error. You can also set an error on the WidgetList itself (e.g. as a + title and hint but each element of the dict can have its own + error. You can also set an error on the WidgetDict itself (e.g. as a result of higher-level processing). Instance attributes: @@ -874,7 +874,7 @@ element_value_type=StringWidget, element_key_kwargs={}, element_value_kwargs={}, - element_name='row', **kwargs): + add_element_label='Add row', **kwargs): assert value is None or type(value) is dict, ( 'value %r not a dict: got %r' % (name, value)) assert issubclass(element_key_type, Widget), ( @@ -918,7 +918,7 @@ add_element() # Add submit to add more element widgets - self.add(SubmitWidget, 'add_element', value='Add %s' % element_name) + self.add(SubmitWidget, 'add_element', value=add_element_label) if self.get('add_element'): add_element() num_added += 1