Am 05.03.10 18:18, schrieb Patricio Valarezo Lozano:
Diez B. Roggisch wrote:
Am 05.03.10 17:57, schrieb Patricio Valarezo Lozano:
Hi friends, I'm trying to use toscawidgets for a mixed form with
WidgetLists or child widgets, where can I find code samples for widgets
constructed in real time?, or ways to manipulate the child widgets to
append widgets, the widget I want to acomplish has this layout:
FormTable:
TextField,
<widget list of SimpleSelectField constructed on object instantiation>
I don't understand this question.
Do you want to know how to dynamically set the optionlist of a
SingleSelectField?
If yes, use a callable as options-parameter. You can e.g. parametrize
that through the tmpl_context.
Normally, child_args=dict(field_name=dict(options=<list_of_options>))
should work, too, but AFAIK that's not working - a bug that I'm
investigating.
Diez
Not really, I want to make a kind of compount widget, with sub widgets
constructed from dynamic source, something like this:
class MainForm(FormTable):
name = TextField
def __init__(self,regs=[]):
for r in regs:
# create child widgets
regs = # some registers from the db
mf = MainForm(regs)
I hope this is more clear now,
It is, but it's a bad idea. ToscaWidgets doesn't work that way, widgets
are supposed to be "static".
What is your actual use-case? You might use things like
FormField-repeater, or a mapped list of forms/child-widgets. Or you can
simply create your own FormField subclass that renders whatever HTML you
need.
The one thing you shouldn't do is to dynamically allocate widgets.
Diez
--
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.