On Jan 18, 2007, at 3:51 PM, Christopher Arndt wrote:


David E schrieb:
Notably, it looks like when using your widget you can try
add_people_form(value=dict(lastname='joe'))

Yes, this is correct. See also here:

http://docs.turbogears.org/1.0/SimpleWidgetForm#form-display-revisited

This might be useful too:

http://docs.turbogears.org/1.0/RoughDocs/WidgetsOverview#tips

The arguments-to-children tip only applies to ToscaWidgets (docs should state this more clearly and provide TG's way of doing it). To pass arguments to child widgets in TG widgets another syntax must be used.

in TW:

form.display(value, **{'.address':{'repetitions':3}})

in TG:

form.display(value, repetitions=dict(address=3))

(An astute reader might notice that TG widgets wouldn't allow passing a 'repetitions' argument to a child if the form had a 'repetitions' argument too... ;)


(though I don't know why the inner widget is prefixed with a dot in the example
given on the latter page)

This is to tell TW that args. are to be passed to child widgets, it's actually a shortcut for:

form.display(value, child_args=dict(address=dict(repetitions=3)))

If it wasn't for that the form wouldn't have a clue that those args were meant to be passed to a child widget.

This notation can be used to pass arguments to arbitrarily nested widgets including those that are repeated. Say you need to pass an 'options' argument the the 'foo' singleselectfield in the third 'address' fieldset, you would do:

 form.display(value, **{'.address-2.foo':{'options':[1,2,3]}})

which s a shortcut for:

form.display(value, child_args(address=[{}, {}, dict(child_args=dict (foo=options=[1,2,3]))]))

This is one of the many API improvements ToscaWidgets has. I'm planning to make a first-alpha early next week (or maybe tomorrow along with TG 1.0.1) and write up some more examples and maybe a quick tutorial. If time and my memory allow (I haven't used TG widgets for months) I'd like to point out TG and TW main differences in the widget API to ease migration for those interested.

Alberto

BTW, Nice write-up at http://docs.turbogears.org/1.0/RoughDocs/ FormValidationWithSchemas! :)

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to