ok im going crazy here... Ive tried every example or solution i can find
and nothing works for me...I am trying to build a Time Card app so i can
keep track of employees time cards and I want to make sure only one card
per employee per day can be submitted... So the two fields need to validate
as unique.... however I cannot seem to get anything to work... this is what
I have right now
MODEL:db1.py
db.define_table('employee',
Field('fname', 'string',requires=IS_NOT_EMPTY(),
label='First Name'),
Field('mname', 'string', label='Middle Name'),
Field('lname', 'string',requires=IS_NOT_EMPTY(),
label='Last Name'),
Field('office', 'string'),
Field('title', 'string'),
Field('startdate', 'date'),
Field('birthdate', 'date'),
Field('driverlic', 'string', label='Drivers Lic#'),
Field('address', 'text'),
Field('notes', 'text'),
format ='%(fname)s'
)
db.define_table('timecard',
Field('tc_date','date', IS_DATE(format=('%d-%m-%Y'))),
Field('employee', 'reference
employee',requires=IS_IN_DB(db,'employee.id','%(fname)s %(lname)s')),
Field('myid', unique=True, compute=lambda r:
str(r.tc_date)+str(r.employee))
)
db.timecard.myid.requires=IS_NOT_IN_DB(db,(db.timecard.myid==request.vars.myid),'timecard.myid')
CONTROLLER:default.py
def create_timecard():
form = SQLFORM(db.timecard)
form.process(next='build_timecard/[id]')
return dict(form=form)
simple tests show multiple timecard.myid values
timecard.idtimecard.tc_datetimecard.employeetimecard.myid642013-11-292
2013-11-292652013-11-2922013-11-292662013-11-2922013-11-292672013-11-292
2013-11-292
I am completely lost as everything I have tried has no effect....
--
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.