Massimo code should have been :

db.reservations.PersonName.default = session.PersonName

And you must use it, because the way you made it works will prevent your
user to change their name, let say for instance that 2 differents persons
order with the same form, the second person (if it has input his name) will
be override by the content of session.PersonName, that still content the
name of the person one since you pass it to form.vars.PersonName directly...

Richard




On Sat, Feb 8, 2014 at 5:18 AM, Davy Jacops <[email protected]> wrote:

> Massimo
>
> Thank you for your suggestion.
> In fact the code suggested gives an error:
>
> SyntaxError: Object exists and cannot be redefined: PersonName
>
>
> But your hint pointed me in the right direction.
> The following works:
>
> def reserve():
>      form  = SQLFORM(db.reservations)
> *     form.vars.PersonName = session.PersonName*
>      if form.process().accepted:
>           session.PersonName = form.vars.PersonName
>      return dict(form=form)
>
>
>
> Thanks again
> Davy
>
>
>
> Op zaterdag 25 januari 2014 22:49:45 UTC+1 schreef Massimo Di Pierro:
>
>> You can use session to pre-populate the form.
>>
>> def reserve():
>>      db.reservations.PersonName = session.PersonName
>>      form  = SQLFORM(db.reservations)
>>      if form.process().accepted:
>>           session.PersonName = form.vars.PersonName
>>      return dict(form=form)
>>
>>
>> On Friday, 24 January 2014 23:47:08 UTC-6, Davy Jacops wrote:
>>>
>>> In web2py, making a ticket reservation form
>>>
>>> Simplified db view:
>>>
>>> db.define_table('shows', Field('ShowName', 'string'))
>>> db.define_table('reservations',
>>>                  Field('PersonName','string'),
>>>                  Field('NbrOfTickets','integer'),
>>>                  Field('show_id',db.shows))
>>> db.reservations.show_id.requires = IS_IN_DB(db, db.shows.id, '%(ShowName)s')
>>>
>>> When making a reservation: People need to first fill their name, then
>>> select a show from a drop-down and amount of tickets.
>>>
>>> All this works fine, BUT: I want people to be able to make reservations
>>> for more than 1 show! But people don't like to fill their name more than
>>> once...
>>>
>>> *So the question is: how can I make a form (or wizard) which allows
>>> people to fill out only once their name, and then get the possibility to
>>> fill out several (amount unknown upfront) forms where they select 1 show +
>>> amount of tickets.*
>>>
>>> If all this can be done without wizard, also fine for me.
>>>
>>> Thank you for your help!
>>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to