I just discovered the problem, the fields in the attribute fields should be
quoted without the table name:

form = SQLFORM(Solicitacao, fields=['almoxarifado_id'])

Thanks,

Fabiano


2014-06-02 20:15 GMT-03:00 Fabiano Almeida <[email protected]>:

> Hi,
>
> Showing my code:
>
> Solicitacao = db.define_table("solicitacao",
>       SQLField("solicitante_id", db.auth_user, default=me),
>       SQLField("responsavel_id", db.auth_user, label='Responsável'),
>       SQLField("almoxarifado_id", db.almoxarifado, notnull=True,
> label='Almoxarifado'),
>       SQLField("cadastro", "datetime", notnull=True, default=request.now),
>       SQLField("efetivado", "datetime"))
> Solicitacao.solicitante_id.requires=IS_IN_DB(db, 'auth_user.id')
> Solicitacao.responsavel_id.requires=IS_IN_DB(db, 'auth_user.id')
> Solicitacao.almoxarifado_id.requires=IS_IN_DB(db, 'almoxarifado.id',
> '%(nome)s')
>
> def cadastro():
>         form = SQLFORM(Solicitacao, fields=[Solicitacao.almoxarifado_id])
>         return dict(form=form)
>
>
> Error:
>
> File "/home/fabiano/web2py/applications/gse/controllers/solicitacao.py",
> line 30, in cadastro
>     form = SQLFORM(Solicitacao, fields=[Solicitacao.almoxarifado_id])
>   File "/home/fabiano/web2py/gluon/sqlhtml.py", line 1059, in __init__
>     if fieldname.find('.') >= 0:
> AttributeError: 'Field' object has no attribute 'find'
>
> Thanks,
>
> Fabiano.
>
>
> 2014-06-02 19:17 GMT-03:00 Anthony <[email protected]>:
>
> Should be db.Solicitacao.almoxarifado_id.
>>
>> Anthony
>>
>>
>> On Monday, June 2, 2014 5:11:18 PM UTC-4, Fabiano Almeida wrote:
>>>
>>> Hi,
>>>
>>> Can I use fileds option in normal SQLFORM ? How?
>>>
>>> I tried:
>>>
>>>         form = SQLFORM(Solicitacao, fields=[Solicitacao.
>>> almoxarifado_id])
>>>
>>> And has error.
>>>
>>> thanks,
>>>
>>> Fabiano.
>>>
>>  --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to