Hi Jason,

onvalidation runs before the record is inserted so form.vars.id does
not have a value yet.

You have to move the code from conference_form_details and place it
after the accepts.

Denes.


On Jan 25, 9:11 am, Jason Brower <[email protected]> wrote:
> I have this...
> def create_event():
>      '''
>      INFO:This is the page that creates events.
>      '''
>      form = SQLFORM(db.conference)
>      if form.accepts(request.vars, session, onvalidation =
> conference_form_details):
>          session.flash = "Great!  Your conference is created!"
>      return dict(form = form)
>
> def conference_form_details(form):
>      form.vars.creator = auth.user.id
>      role_id = 1 #The is the event administrator id'
>      print form.vars
>      db.user_role.insert(user_id = auth.user.id, role_id = 1,
> conference_id = form.vars.id)
>      db.commit()
>
> in particular I thought that this:
> form.vars.id
> would give me the id that was to be used in this form, but I think I am
> wrong as it returns None and printing form.vars shows key of 'id'
> Any ideas how to get the id?
> ---
> Best Regards,
> Jason Brower

Reply via email to