Thanks for the feedback. I have been making progress but not quit
there.
Massimo - I did find some logic problems with my initial select that
were contributing to the problem.
Anthony - I do think that how the form is being populated is part of
the problem

I've been trying to build this incrementally to see at what point I'm
having a problem and I've narrowed it down to the SQLFORM.
I can successfully create a record manually using this code.

    event_users = db((db.event_users.event==event_id) &
(db.event_users.user_name==auth.user.id)).select(groupby=db.event_users.user_name).first()
    user = event_users.id
    date = date.today()
    value = '111'
    db.entries.insert(user=user, date_entered=date, value=value)

I can also successfully create a record when I use SQLFORM and have
the user enter all fields.
But I don't want them to enter the user or date. I want the user to
enter only the value and have the other fields be pre-populated.
When I put it all together with the following code I get the errors.

    event_users = db((db.event_users.event==event_id) &
(db.event_users.user_name==auth.user.id)).select(groupby=db.event_users.user_name).first()

    form = SQLFORM(db.entries)
    form.vars.date_entered = date.today()
    form.vars.user = event_users.id
    if form.process().accepted:
        response.flash = 'form accepted'
        redirect(URL('home'))
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'

Adrian

On Nov 22, 9:24 am, Anthony <abasta...@gmail.com> wrote:
> On Tuesday, November 22, 2011 12:30:42 AM UTC-5, Adrian Edwards wrote:
>
> >     form = SQLFORM(db.entries)
> >     form.date_entered = date.today()
> >     form.user = user
> >     if form.process().accepted:
>
> > But the form won't submit. When I debug it through Eclipse it says
> > "lazyT: value not in database"
>
> I don't think this is related to your error, but note that to pre-populate
> fields, you need to set form.vars.fieldname, not form.fieldname.
>
> Anthony

Reply via email to