If the reference is to a different table, the CRUD renders the field as a list box allowing the user to select the record in the foreign table. But as a self-join the CRUD renders the field as a simple text box and it seems to create a default value of 0 when saved. Then, I think that causes the record to generate an error when viewed ( but not when edited).
On 27 November 2012 14:23, Massimo Di Pierro <massimo.dipie...@gmail.com>wrote: > In which way this is not working correctly? > > > On Monday, 26 November 2012 12:45:22 UTC-6, Luc Chase wrote: >> >> The documentation at >> http://web2py.com/books/**default/chapter/29/06?search=** >> reference#Self-Reference-and-**aliases<http://web2py.com/books/default/chapter/29/06?search=reference#Self-Reference-and-aliases> >> says that this should be possible. >> >> However my models code in db_wizard.py which I've partially edited just >> for this requirement does not generate the correct CRUD form ( a lookup >> list-box). What do I need to change to make this work correctly? >> >> Here is my models code... >> db.define_table('t_project', >> Field('f_name', type='string', >> label=T('Name')), >> Field('f_parent_project', type='reference t_project', >> label=T('Parent Project')), >> Field('f_description', type='string', >> label=T('Description')), >> Field('f_start_on', type='date', >> label=T('Start On')), >> Field('f_colour', type='string', >> label=T('Colour')), >> Field('f_company_code', type='text', >> label=T('Company Code')), >> Field('f_status', type='boolean', >> label=T('Status')), >> auth.signature, >> format='%(f_name)s', >> migrate=settings.migrate) >> > -- > > > > -- Luc. M. +44.7040-901-582 --