Jorge Godoy wrote:
"glenn" <[EMAIL PROTECTED]> writes:

> hi
> im trying to use a TableForm with a TextField (passed in as a
> widgetList). Because its for a new record, im passing in values="".
> What Im getting in my browser is an input text field with
> <built-in method title of str object at 0xb7dbc098> as the 'value'.
>
> Is there an  easy way I can surpress that message?

Use the widget the correct way.  Send some code to the list.  You are not
doing what you think you're doing.

Yes, I can accept this is entirely possible.

What I think im doing is passing in an instance of a model as the
'value' clause to a TableForm widget - which is as per bookmark example
in chp5 of tg book. The difference is when the book does this it is not
doing it for a new record, but for an existing record - which works as
expected. I also  tried passing value="", but get different but similar
result.

ok for code (controller):
---------
class ProjectFields(widgets.WidgetsList):
 title=widgets.TextField(validator=validators.NotEmpty)
clientID=widgets.SingleSelectField(validator=validators.NotEmpty,
options=get_client_list_as_options)

project_formwidget =
widgets.TableForm(fields=ProjectFields(),submit_text="Save Project")

class Root(...):
....
....
   @expose(template="contractime.templates.project_edit")
   def project(self,*args):
     if not args or args[0] == "add":
       submit_action="/save_project/"
       p = ''
     from sqlobject import SQLObjectNotFound
     try:
       p = Project.get(args[0])
       submit_action="/save_project/%s" %args[0]
       #project_formwidget.fields[1].default=p.clientID
     except:
       p = ''
     return
dict(form=project_formwidget,values=p,action=submit_action)

   @expose()
   def save_project(self,*args,**kwargs):
     from sqlobject import SQLObjectNotFound
     if args:
       try:
         p=Project.get(args[0])
         p.set(**kwargs)
       except SQLObjectNotFound:
         Project(**kwargs)
     else:
         Project(**kwargs)
     raise redirect("/project")

---view (template:project_edit.kid)---
...
<body>
 ${form(value=values,action=action)}
</body>
...
---------------------------
I notice many people pass in key value pairs, but, well... I dont want
to have to - It seems I can almost get away with just passing in the
object (p) and I'd like to make this work.

would love to be find what it is im not doing, or am actually doing.
Thanks


--
Jorge Godoy      <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
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