It depends on what specifically you are trying to accomplish.
You could set the validator instead, for example:
rr=db(db.food.name.like('m%')).select()
db.ate.food_id.requires=IS_IN_SET([(r.id,r.name) for r in rr])
Denes
On Mar 26, 6:26 pm, Avik Basu <[email protected]> wrote:
> Is there a way to pass arguments to a field's widget from the
> controller? For example:
>
> db.define_table("food", Field("name", "string'"))
>
> db.define_table("units",
> Field("food_id", db.food),
> Field("name", "string")
> )
>
> db.define_table("ate",
> Field("food_id", db.food),
> Field("quantity", "double"),
> Field("units", "string", widget=units_widget),
> )
>
> In an update form for "ate", I would like to create a dropdown box of
> units that are associated with a given food_id. I realize could not
> be set in the db.py since the food id would be unknown in that scope,
> however the action in the controller would have access to the food id,
> but I would like to be able to pass that somehow to the widget.
>
> Thanks,
> Avik
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en.