The problem is here:
db.adres.adressoort.widget=lambda f,v: OptionsWidget.widget(SQLField
('adressoort',db.adressoort,requires=db.adres.adressoort.requires
[0]),v)
because you are creating a widget for a new temp field that is
associated to a table. I understand what you are trying to do. Let me
think of a better way. For now you can try:
tmp=SQLField
('adressoort',db.adressoort,requires=db.adres.adressoort.requires[0])
tmp._tablename=db.adres.adressoord._tablename
db.adres.adressoort.widget=lambda f,v: OptionsWidget.widget(tmp,v)
Massimo
On Jul 4, 7:07 am, annet <[email protected]> wrote:
> In a validator I combine IS_IN_DB() and IS_NOT_IN_DB. I tried solving
> the 'no automatic drop box' issue by adding a widget based on an
> unnamed function:
>
> db.define_table('adressoort',
> db.Field('soort',length=30,default='',notnull=True,unique=True),
> migrate='adressoort.table')
>
> db.adressoort.soort.requires=[IS_LENGTH(30,error_message='lengte
> overschreidt 30 tekens'),IS_NOT_EMPTY(),IS_NOT_IN_DB
> (db,'adressoort.soort',error_message='soort niet uniek')]
> db.adressoort.soort.label='Soort * '
>
> db.define_table('adres',
> db.Field
> ('bedrijf',db.bedrijf,default='',notnull=True,ondelete='CASCADE'),
> db.Field
> ('adressoort',db.adressoort,default='',notnull=True,ondelete='RESTRICT'),
> db.Field(...),
> migrate='adres.table')
>
> ...
> db.adres.adressoort.requires=[IS_IN_DB(db,db.adressoort.id,'%(soort)
> s',orderby=db.adressoort.id),IS_NOT_IN_DB(db
> (db.adres.bedrijf==request.vars.bedrijf),db.adres.adressoort)]
> db.adres.adressoort.widget=lambda f,v: OptionsWidget.widget(SQLField
> ('adressoort',db.adressoort,requires=db.adres.adressoort.requires
> [0]),v)
> ...
>
> this results in an error:
>
> File "/Library/Python/2.5/site-packages/web2py_1_65_0/gluon/
> sqlhtml.py", line 50, in _attributes
> _id = '%s_%s' % (field._tablename, field.name),
> AttributeError: 'SQLField' object has no attribute '_tablename'
>
> I wonder whether this problem has been solved with the introduction of
> version 1.65. I read the slides, but the examples are all based on an
> IS_IN_SET() validator, not on a table field.
>
> Kind regards,
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---