On Thursday, October 6, 2016 at 5:59:46 AM UTC-4, Ramos wrote:
>
> Hello i found a bug that does not produces any kind of error.
>
> When i have
>
> define_table(''thistable'
> Field("field",db.othertable)
> )
>
> othertable must be declared before thistable,otherwise i get an error
>
Yes, that is as expected -- the db object will have no "othertable"
attribute if othertable has not been defined yet.
> But if i change this code to
>
> define_table(''thistable'
> Field("field",'list: reference othertable')
> )
> if i declare othertable after thistable i dont get any error and only get
> this field as List of String instead of list of fields in othertable
>
The above works, and it is *not* a list:string field. Rather, when you
define a reference field (whether a plain reference field or a
list:reference field) *before* the referenced table is defined, then you
don't get the standard default IS_IN_DB validator nor the default
"represent" attribute. The former determines the widget that is shown in
SQLFORMs, and the latter (in conjunction with the "format" attribute of the
referenced table) determines the display in read-only forms and grids. The
field is defined and working as expected, but if you are interacting with
it via web2py forms and grids, the display may not be what you expect. You
will have to explicitly define the "requires" and "represent" attributes
(and possibly the "widget" attribute, if you don't specify a validator that
SQLFORM can use to generate the widget you desire).
Anthony
--
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.