After:
db.define_table('test',
Field('name', writable=False),
Field('refers_to', 'reference test'))
add
db.test.referes_to.requires=IS_EMPTY_OR(IS_IN_DB(db,'test.refers_to'))
or it will not take a empty reference.
On a second thought... this should probably be the default behavior
for self-references.
On Oct 16, 5:10 pm, BigBaaadBob <[email protected]> wrote:
> If I have this model:
>
> db.define_table('test',
> Field('name', writable=False),
> Field('refers_to', 'reference test'))
>
> And this controller function:
>
> def create():
> db.test.name.default=request.args(0)
> form = crud.create(db.test, next = URL('index'))
> return dict(form=form)
>
> And go to URL .../create/xyzzy, I get the expected form but when I
> submit I get a ticket with this exception:
>
> Exception: <type 'exceptions.ValueError'>(invalid literal for int()
> with base 10: '')
>
> referring to this code:
>
> if field.type == 'integer':
> if fields[fieldname] != None:
> fields[fieldname] = int(fields[fieldname])
> elif str(field.type).startswith('reference'):
> if fields[fieldname] != None and
> isinstance(self.table,Table) and not keyed:
> fields[fieldname] = int(fields[fieldname])
>
> elif field.type == 'double':
> if fields[fieldname] != None:
> fields[fieldname] = float(fields[fieldname])
>
> What dumb thing did I do?