I managed to get it going, thanks for highlighting that mistake 














*form=SQLFORM(db.store_registration)    if form.process().accepted:        
response.flash=T('Details Registered')        student_id = 
form.vars.id_number        # Redirect to payments view with student's name 
as parameter        redirect(URL('default', 'payments', vars={'student_id': 
student_id}))    return locals()def payments():    student_id = 
request.vars.student_id    # Load student's information from the database  
  student = db(db.store_registration.id_number == 
student_id).select().first()        if student is None:        raise 
HTTP(404, "Student not found")*









*    db.payments.student.default=student.id    form = SQLFORM(db.payments)  
  #form.vars.student = student.id  # Set the student reference in the 
payment form    if form.process().accepted:        response.flash = 
T('Payment details submitted')        redirect(URL('default', 
'student_registration'))    return locals()*

On Sunday, August 20, 2023 at 3:25:43 PM UTC+2 Clemens wrote:

> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/9525a8bb-682d-4f8a-adb1-7685ee81d26bn%40googlegroups.com.

Reply via email to