Dear all,

I have a form builded using the SQLFORM.factory method with just one field. This is the code:

    #mset = db(source_table).select(source_table.municipio, 
orderby=source_table.municipio, distinct=True)
    field = Field('municipio', requires=IS_EMPTY_OR(IS_IN_DB(db, '%s.municipio' 
% source_table._tablename, '%(municipio)s', distinct=True)))
    #field = Field('municipio', requires=IS_EMPTY_OR(IS_IN_SET([(rec, 
rec.municipio) for rec in mset])))
form = SQLFORM.factory(
        field
    )

the strange behaviour is that it does not accept any value proposed by its validator because of this difference between the value it sets up in form.vars[1] and the one I can get from a query on my db table[2]. i.e.:

ipdb> form.vars
<Storage {'municipio': '- IV - \r\nVAL BISAGNO'}> # <--- [1]

ipdb> res = db(source_table).select(source_table.municipio, orderby=source_table.municipio, distinct=True)
ipdb> res[3]
<Row {'municipio': '- IV - \nVAL BISAGNO'}> # <--- [2]

the problem seams to be the carriage return character "\r" introduced (maybe) from the form interface.

The problem is by-passed using the other field definition commented out up above using the validator IS_IN_SET.

I think this could be considered as a bug... I hope it could help.

Cheers

    Manuele

--



Reply via email to