How can I make the 'barcode' field in bursary_entries reference/depend upon
a 'barcode' entry in bursary_users? Do I just have to alter my field to:
I was trying to make sense of what was needed here and I thought 'requires'
was the best way of doing it, but does that only work for the primary key?
Thanks for your help.
On Friday, October 14, 2016 at 7:49:17 PM UTC+1, Val K wrote:
> 'reference bursary_users' and requires = [IS_IN_DB(db, 'bursary_users
> .barcode')] - I think, that it's mutually exclusive requirements
> 'reference bursary_users' == requires = IS_IN_DB(db, 'bursary_users.*id*')
> On Friday, October 14, 2016 at 6:21:38 PM UTC+3, James Booth wrote:
>> Hey guys,
>> Excuse me if I'm missing something (or a lot), but I'm pretty experienced
>> with web2py.
>> I have the following defined in my model:
>>> Field('forename', type='string',
>>> Field('surname', type='string', requires=IS_NOT_EMPTY()),
>>> Field('studentId', type='string',
>>> requires=IS_NOT_EMPTY(), unique=True),
>>> Field('barcode', type='string', requires=IS_NOT_EMPTY(),
>>> Field('email', type='string', requires=IS_EMAIL(),
>>> Field('bursary', requires=IS_IN_SET(['Free school
>>> Field('notes', type='text'),
>>> Field('barcode', 'reference bursary_users', requires =
>>> [IS_IN_DB(db, 'bursary_users.barcode')]),
>>> Field('entry_date', type='datetime',
>>> default=request.now, readable=False, writable=False),
>> When I use the SQLFORM on a page, I can enter a barcode and it validates
>> it (Fails if not in bursary_users, pass if it is). However, when I come to
>> check the database, I'm getting a '0' (Althought it is hyperlinked to
>> nothing) for the barcode value and a correct value for the entry_date.
>> Any ideas why this is happening?
>> Kind regards,
- 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
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.