Hmm, you are using WidgetsDeclaration, but I use WidgetsList to
declare my list of fields.
Which one should I use and what are the differences?
Will
On Sep 17, 10:50 pm, krsyoung <[EMAIL PROTECTED]> wrote:
> On Sep 17, 6:13 pm, shadowfox <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > Is there any online tutorial or threads where Field List are used to
> > construct an Edit page for an object?
>
> > In other words, how do I pass the current values of the object and
> > present the users with the ability to change them?
>
> > Thanks,
> > Will
>
> Hey Will,
>
> I usually do the following:
>
> model.py:
> class MyObject(SQLObject):
> bar = StringCol()
>
> controllers.py:
> class Foo(widgets.WidgetsDeclaration):
> bar = widgets.TextField(validator=validators.NotEmpty)
>
> foo_form = widgets.TableForm(fields=Foo())
>
> class Root(RootController):
> @expose(template="edit")
> def edit(self, id, **kwargs):
> # add in try/except statement here
> mo = MyObject.get(id)
> values = dict()
> values['bar'] = mo.bar
> return dict(form=foo_form, values=values, action='/save_edit')
>
> edit.kid:
> ${form(value=values, action=action)}
>
> Should do the trick...I can't seem to find a good link to a full
> tutorial right now but I'm sure they exist. Also, you might want to
> try this link to save yourself some
> work:http://docs.turbogears.org/1.0/CRUDTemplate
>
> Good luck
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---