You did not set any validator.Validators will be set outomatically if
you teach web2py how to represent records in the referenced tables:
db.define_table('tablefoo',
Field('foo', length=5),
format='%(foo)s')
db.define_table('tablebar',
Field('bar', length=5),
format='%(bar)s')
db.define_table('tablefoobar',
Field('foo_ref', db.tablefoo),
Field('bar_ref', db.tablebar)
)
On Aug 22, 4:11 pm, Niphlod <[email protected]> wrote:
> hello everybody.....with this model I get some really strange
> behaviours....is this a bug or a web2py limitation ?
>
> db.py
>
> -------------------
>
> db.define_table('tablefoo',
> Field('foo', length=5)
> )
>
> db.define_table('tablebar',
> Field('bar', length=5)
> )
>
> db.define_table('tablefoobar',
> Field('foo_ref', db.tablefoo),
> Field('bar_ref', db.tablebar)
> )
>
> -------------------
>
> so, I have two tables, tablefoo and tablebar with some values in it
> and tablefoobar would have to store all the possible "connections"
> between tablefoo and tablebar.
> put 5 rows in tablefoo, 5 rows in tablebar and....
>
> 1st weird thing: appadmin/insert/db/tablefoobar returns two text
> inputs:
> <input type="text" value="" name="foo_ref" id="tablefoobar_foo_ref"
> class="reference tablefoo">
> class is "reference" so there's clearly something wrong with that...
>
> 2nd weird thing: no costraint on insertion , form is always accepted
> (obviously if you try later to visualize the field in appadmin/update/
> db/tablefoobar/1 a ticket is returned)
>
> 3rd weird thing: appadmin/update/db/tablefoobar/1 if you insert
> meaningful records (i.e. existing in tablefoo and tablebar,
> respectively) , it ends up having:
> <input type="text" value="1" name="bar_ref" id="tablefoobar_bar_ref"
> class="reference tablebar">
> at least, it's coherent :-P
>
> I tried also creating a controller and enforcing IS_IN_DB(), then
> creating a form..... I end up having the same bahaviour...