What is this line all about?

db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)

Also, these lines in your t_user_has_companies table def don't match what 
you say about them.
>>>  Field('first_name', 'reference auth_user', label='User', 
writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
%(last_name)s')),
>>>  Field('f_coname', 'reference t_companies', label='Company', 
writable=True, readable=True, notnull=True, required=True, ondelete='NO 
ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s %(f_coname)s'))

>>>I also defined User_Has_Companies which has 2 columns USER_ID and 
COMP_ID together should form a PK.

You don't need the "required" attributes as they are covered by IS_IN_DB. 
Why do you have the ondelete in there?

DAL doesn't support multi-column primary keys. 

This is awfully ambitious. Why don't you cut out a lot of the code and see 
if you can get it working something like the example in the on-line manual?


On Friday, December 13, 2013 3:48:14 PM UTC-5, Michel Hayek wrote:
>
> Hi guys,
>
> I have 2 tables defined Auth_User(PK=id) and Companies(PK=ID)
> I also defined User_Has_Companies which has 2 columns USER_ID and COMP_ID 
> together should form a PK.
>
> *db.py:*
>
>
>
> *#################################db.define_table('t_companies',          
>       Field('f_coname',label='Company Name', required=True,ondelete='NO 
> ACTION',notnull=True),                Field('f_comanager',label='Company 
> Manager', required=False,ondelete='NO ACTION',notnull=False),              
>   Field('f_coemail',label='Company Email', required=False,ondelete='NO 
> ACTION',notnull=False)                )db.t_companies.f_coemail.requires = 
> IS_EMAIL(error_message='invalid 
> email!')####################################*
> *db.define_table('t_user_has_companies',*
> *                Field('first_name', 'reference auth_user', label='User', 
> writable=True, readable=True, notnull=True, required=True,  ondelete='NO 
> ACTION', requires=IS_IN_DB(db, db.auth_user, '%(id)s %(first_name)s 
> %(last_name)s')),*
> *                Field('f_coname', 'reference t_companies', 
> label='Company', writable=True, readable=True, notnull=True, required=True, 
> ondelete='NO ACTION', requires=IS_IN_DB(db, db.t_companies, '%(id)s 
> %(f_coname)s'))*
> *           )*
>
> *db.t_user_has_companies.first_name.requires=IS_NOT_IN_DB(db(db.t_user_has_companies.f_coname==request.vars.f_coname),db.t_user_has_companies.first_name)*
>
> *In default.py:*
> *@auth.requires_login()*
> *def usercompanies():*
> *    grid=SQLFORM.grid(db.t_user_has_companies)*
> *    return locals()*
>
> it works fine but the problem is i only get one drop down for the 
> companies, as for the User it appears a text box. How this one also be set 
> to drop down box?
>
> Thanks
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to