On Tuesday, August 30, 2011 6:42:20 PM UTC-4, brushek wrote:
>
>
>
> On 31 Sie, 00:03, Bruno Rocha <rocha...@gmail.com> wrote: 
> > as far as I know, this line "db.dog.owner.requires=IS_IN_DB(db, '
> person.id')" 
> > is responsible for the dropdown widget. 
> > 
> > It is a validator, but using it implies the use of widget. 
> > 
> > if you do not use the IS_IN_DB(..) you will have no widget, then will be 
> > only a text box field to input the id. 
> > 
>
> Hm... So You suggests, that if I remove the line 
> db.dog.owner.requires=IS_IN_DB(db, 'person.id') I should get 
> in form generated by SQLFORM text box ? If so, then something is 
> wrong, because I get the select box with numbers (id's from person 
> table). 
>

Because db.dog.owner is a reference field, it automatically gets the 
following validator by default:

db.dog.owner.requires=IS_IN_DB(db, 'person.id', db.person._format)

So, by default, it uses db.person._format (which in this case is 
'%(name)s'), which displays the names instead of the ids. However, you have 
overridden the default validator with your own IS_IN_DB, but you did not 
specify a format. If you don't specify a format in IS_IN_DB, it defaults to 
'%(id)s', which is why you see ids instead of names.

Anthony

Reply via email to