Thanks for this method

Il giorno giovedì 28 aprile 2016 20:10:46 UTC+2, Val K ha scritto:
>
> 'form.vars.field = any'  must be placed before form.process()
> So, in your case:
>     form = SQLFORM(db.pratiche)
>     form.vars.stato_pratica = 'aperta'
>     
>     if form.process().accepted:
>
>     ...
>     form.add_button('Back', URL('index'))  #  it's a DOM-manipulation - 
> place it after form.process()
>    
>
>
>
> On Friday, April 22, 2016 at 12:23:59 AM UTC+3, Andrea Marin wrote:
>>
>> Trans a lot 
>>
>> Il giorno 21 apr 2016, alle ore 05:22, Michael Beller <mjbe...@gmail.com> 
>> ha scritto:
>>
>> before you call SQLFORM, insert:
>> db.pratiche.stato_pratica.default = 'aperta'
>>
>>
>>
>> On Wednesday, April 20, 2016 at 6:05:06 PM UTC-4, Andrea Marin wrote:
>>>
>>> Hi I have this type of form in my model file:
>>>
>>> db.define_table('pratiche',
>>>                 Field('nome', requires=IS_NOT_EMPTY()),
>>>                 Field('descrizione', 'text', requires=IS_NOT_EMPTY()),
>>>                 Field('tipo_allegato', requires=IS_IN_SET(['mandato', 
>>> 'comparsa preliminare', 'relazione ctu', 'parcella'])),
>>>                 Field('doc_filename'),
>>>                 Field('doc', 'upload'),
>>>                 Field('stato_pratica', requires=IS_IN_SET(['aperta', 
>>> 'attesa', 'chiusa'])),
>>>                 auth.signature)
>>>
>>>
>>> I want to setup a default value for field stato_pratica to 'aperta' 
>>> every time a user create a new record
>>> This is my controller function to create a new record
>>>
>>> def create():
>>>     form = SQLFORM(db.pratiche).process()
>>>     form.vars.stato_pratica = 'aperta'
>>>     form.add_button('Back', URL('index'))
>>>     if form.accepted:
>>>         session.flash = T('Posted')
>>>         redirect(URL('index'))
>>>     elif form.errors:
>>>         session.flash = T('Il form ha degli errori')
>>>     return locals()
>>>
>>> I try to set form.values.stato_pratica = 'aperta' but it not works.
>>>
>>> Thanks.
>>>
>>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/QJ1aaP5Febo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com.
>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to