2008/4/24, Jorge Vargas <[EMAIL PROTECTED]>:
>
> > To get to know TG I am trying to start writing a blog application. In my
> > controller I have:
> > #####
> > @expose(template='kid:tblog.BlogEntryController.templates.form')
> > def new(self, **kw):
> > return dict(modelname = self.modelname,
> > data = dict(authorID =
> identity.current.user.id),
>
> here is your problem data is actually 2 values
> data = {
> authorID = 1
> }
>
> therefore when the widget looks for data it's returning 'authorId' as
> that's the first entry.
> you can fix this in several ways.
> if you want to keep that dict (only worth it if you have more values for
> it.
> change the template to
> > ${form(value = data['authorId'], action = 'save', submit_text =
> "Create")}
> if you don't want to keep that dict
> change the controller to be
>
> return dict(modelname = self.modelname,
>
> authorID = identity.current.user.id,
> ....
>
I know have:
@expose(template='kid:tblog.BlogEntryController.templates.form')
def new(self, **kw):
"""Create new records in model"""
log.info(identity.current.user.id)
return dict(modelname = self.modelname,
authorID = identity.current.user.id,
form = model_form,
page ='new')
and
#${authorID}#
${form(value = authorID, action = 'save', submit_text = "Create")}
authorID is expanded to 1, but the hidden field stil does not get a value.
Is there a description of ${form()}? (I did not find anything.) Then I could
study that.
--
Cecil Westerhof
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---