This form inserts two records, the first containing only the submitted
data ('choice') and the second containing the poll and voter ids as
well. I only need the second one. What should I do differently? Sorry,
I'm sure the solution is obvious to everyone but me!
Controller:
def respond():
p = db.poll[request.args(0)]
if not p: raise HTTP(404)
form = SQLFORM(db.choice, fields = ['choice'])
if form.accepts(request.vars):
response.flash='record inserted'
db.choice.insert(voter=auth.user.id,poll=p.id,choice=request.vars.choice)
elif form.errors:
response.flash='there are errors, they are shown in form'
return dict(form=form,poll=p)
View::
{{extend 'layout.html'}}
<div id="main">
<h3>Q: {{= poll.question}}</h3>
{{= form}}
</div>
I tried using FORM instead of SQLFORM but that inserted everything but
'choice'.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en.