Hi,

could it be that the problem is, you're passing the students name 
(vars={'student_name': student_name}) but then reference 
to form.vars.student as student.id?

Regards

On Sunday, August 20, 2023 at 1:04:51 PM UTC+2 mostwanted wrote:

> I have a student registration form that immediately after registering a 
> student I want to use those details in another form, a payments form to 
> enter that student's payment status but my code keeps returning  none like 
> student is not available, I am doing something wrong here please assist me 
> figure it out or show me a better way of doing achieving the same logic:
>
> *CODE:*
> *def registration():*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *    form=SQLFORM(db.store_registration)    if form.process().accepted:    
>     response.flash=T('Details Registered')        student_name = 
> "{form.vars.first_name} {form.vars.last_name}"        # Redirect to 
> payments view with student's name as parameter        
> redirect(URL('default', 'payments', vars={'student_name': student_name}))  
>   return locals()def payments():    student_name = 
> request.vars.student_name    # Loading student's information from the 
> database    student = db(db.store_registration.first_name + ' ' + 
> db.store_registration.last_name == student_name).select().first()        if 
> student is None:        raise HTTP(404, "Student not found")*
>    
> * form.vars.student = student.id <http://student.id>  # Set the student 
> reference in the payment form*
>
>
> *    form = SQLFORM(db.payments)    if form.process().accepted:        
> response.flash = T('Payment details submitted')    return locals()*
>
> Regards
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1896f30b-1d6c-4288-9901-c2e314aa1fc8n%40googlegroups.com.

Reply via email to