Antoine Pitrou schrieb:
> Hello,
>
> I need to populate a RadioButtonList with different options depending
> on the object which is being edited (some objects will have more
> options offered than others). Of course the object id is part of the
> form (as a HiddenField), but looking at the doc (*) it seems that a
> callable parameter isn't given any arguments when it is called. Which
> means that I don't have enough context information to know what values
> to return exactly.
>
> (I worked around this by reading the context directly from the pseudo-
> global `request` variable supplied by TurboGears but this is not very
> pretty IMHO)
You should be able to actually set the options via the
update_params-call of the Form itself. I'm not 100% positive about this,
but it *should* work like this:
class MyForm(TableForm):
...
def update_params(self, d):
super(MyForm, self).update_params(d)
# this should actually check the
# existence of child-args first I guess.
d.child_args["radio_button_list_widget_name"] = dict(options=
options_by_id(d.value_for("hidden_field_name"))
I'll try to throw together a working example if I find the time.
Diez