Replace
Field('firma', db.firma, requires=[IS_IN_DB(db, 'firma.id', '%
(nume)s')]),
with
Field('firma', db.firma, requires=IS_IN_DB(db, 'firma.id', '%
(nume)s')),
or even better
Field('firma', db.firma),
the validator is automatic for reference fields.
Field('firma', db.firma, requires=[IS_IN_DB(db,
'firma.id', '%(nume)s')]),
On Jan 17, 5:11 am, rif <[email protected]> wrote:
> Hi guys,
>
> I just started working with web2py and I like it a lot. I have a
> little problem with the following tables:
>
> The firma field in the second table is shown as a text field where I
> can only enter the ids and not as a select field. I admit that I might
> have saved the db.py with firma field as a string first but now the
> migration does not seem to take place.
> I have other foreign key fields that are working fine but this one is
> giving me troubles. Did I do something wrong here?
>
> If you need more info please let me know.
>
> Keep up the good work!
> Radu
>
> db.define_table('firma',
> Field('nume', required=True, unique=True),
> format='%(nume)s'
> )
>
> db.define_table('angajat',
> Field('firma', db.firma, requires=[IS_IN_DB(db,
> 'firma.id', '%(nume)s')]),
> Field('nume', required=True),
> Field('prenume', required=True),
> Field('norma', 'integer', required=True,
> requires=[IS_INT_IN_RANGE(1,10)]),
> Field('activ', 'boolean', default=True),
> format='%(nume)s %(prenume)s'
> )