Hallo, yes it is newbie question..., but I am new in coding.
I am creating signing form to school events. School event is defined in
table 'schol_event' and signed users to scholl events is defined in table
'event_registration'.
When user send form 'signing_form()' (which add record to table
'event_registration'), I also need update field 'current_quantity' in table
'event_registration'.
I do not know how to achive it. Respectively how to save posted value from
form to variable, which i can use to update required table.
Model (shorted version):
db.define_table('school_event',
Field('title', notnull=True),
Field('event_location', 'string'),
Field('max_quantity', 'integer', IS_INT_IN_RANGE(1,100)),
Field('current_quantity', 'integer'),
Field('posted_by', 'reference auth_user',
default=auth.user_id),
Field('posted_on', 'datetime', default=request.now),
Field('status'))
# Define registration on events for users
db.define_table('event_registration',
Field('signed_user', 'reference auth_user',
default=auth.user_id),
Field('requested_event', 'reference school_event',
requires=IS_IN_DB(db, db.school_event, '%(title)s')),
Field('signed_on', 'datetime', default=request.now))
Controler:
@auth.requires_login()
def signing_form():
"""
Signing form for event
"""
form = SQLFORM(db.event_registration)
if form.process().accepted:
# Here I want to update field 'current_quantity' in table
'school_event'. How to achive it?
response.flash = "OK!"
elif form.errors:
response.flash = "Correct errors!"
else:
response.flash = "Insert required values."
return locals()
Thank you so much,
Pavel
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.