company_field_id and company_id_field are not the same. Look closely.
On Friday, January 22, 2016 at 3:29:47 PM UTC-7, Seraaj Muneer wrote:
>
> Hello everyone again, still taking web2py for a spin but encountering some
> really strange errors.
>
> Here is my data definition
>
> company_field_id = 'company_id'
>
>
> db.define_table('bank', Field('bank_name', 'string', length=25, represent=
> lambda bank_name, row: bank_name.upper(),
> required=True,
> unique=True, notnull=True,
> ),
> Field('default_branch', 'string', default='', length=25,
> requires=[IS_EMPTY_OR(IS_MATCH('^[a-zA-Z][a-zA-Z ]*$'))]),
> Field(company_id_field, 'reference company', notnull=True, ondelete=
> on_delete_cascade,
> writable=False, readable=False), Field('request_tenant', default=auth.
> user_id, writable=False),
> auth.signature, common_filter=lambda query: db.bank.company_id ==
> get_default_company_id(),
> format=lambda r: r.bank_name or 'No bank name!')
> db.bank.bank_name.requires = [IS_NOT_EMPTY(error_message='You must enter
> a bank name'),
> IS_MATCH('^[a-zA-Z][a-zA-Z ]*$',
> error_message='Bank name can only contain alphabets (A-Z)'),
> IS_NOT_IN_DB(db, db.bank.bank_name, error_message='Bank name must be
> unique.')]
>
> db.bank._before_insert.append(
> lambda f: f.update(
> company_id=get_default_company_id()))
>
>
>
>
>
>
> and here is my controller
>
>
> @auth.requires_login()
> def show():
> db(db.company.id > 0).count() or redirect(URL('company', 'create'))
> form = SQLFORM.smartgrid(db.bank)
> return dict(form=form)
>
>
>
>
>
> and here is my view
>
>
> {{extend 'layout.html'}}
> {{=form}}
>
>
>
> Nothing I do gets this to work. Web2py always returns the error as per the
> screenshot attached. I've done a great deal of googling to no avail. Whats
> wrong?
>
>
--
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/d/optout.