Kevin Horn wrote:
> The part of widgets documentation that I'd like to see fleshed out are more
> examples of the FormWidgets and other CompundWidgets.
>

You're right... :-)

> For example, is there a way to set the values of all the widgets contained
> in a CompundWidget at once?  Maybe by passing a list?  This would make forms
> for editing info in the database much simpler.
>

You need to pass a dict to the CompoundWidget, just like you do with a
Form (that's a CompoundWidget), for example:

>>> from turbogears import widgets
>>> class HelloWidget(widgets.Widget):
...     template = "<div>Hello $value</div>"
...
>>> class ManyHello(widgets.CompoundWidget):
...     member_widgets = ["hello_widgets"]
...     hello_widgets = []
...     template = """
...     <div xmlns:py="http://purl.org/kid/ns#";>
...             <div py:for="hello in hello_widgets"
...                     py:content="hello(value_for(hello),
**params_for(hello))"
...             />
...     </div>
...     """
...
>>> many = ManyHello(hello_widgets=[HelloWidget(name="1"), 
>>> HelloWidget(name="2") ], default={'1':'jorge', '2':'alberto'})
>>> print many.render() <DIV>
                <DIV>
                <DIV>Hello jorge</DIV></DIV><DIV><DIV>Hello
alberto</DIV></DIV>
        </DIV>
>>> print many.render(value={'1':'michele', '2':'kevin'})
<DIV>
                <DIV>
                <DIV>Hello michele</DIV></DIV><DIV><DIV>Hello
kevin</DIV></DIV>
        </DIV>

the concept is exactly the same for a Form widget.

Ciao
Michele


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to