Il giorno mercoledì 5 settembre 2012 17:09:41 UTC+2, tommasot ha scritto:
>
> I have the following code in the controller about record creation
>
> *form = crud.create(db.anno,next='list_anno')*
>
> This is the model,how you can see is very simple :)
>
> *db.define_table('anno',
>     Field('descrizione'),
>     Field('incorso','boolean'),format='%(descrizione)s')*
>
> Now i want to catch the 'incorso' value posted from the form and 
> manipulate the value if some condition is satisfied.
>
> The question is how can i intercept the value, i hope there is something 
> like form.field
>
>
> Thanks
>



Thank you for the answers, i have solved with the following code



*def validate_anno(incorso,descrizione):
    if request.vars.incorso == 'on':
        anni = db(db.anno).select()
        for anno in anni:
            anno.update_record(incorso=False) *

*def create_anno():
    form = 
crud.create(db.anno,next='list_anno',onvalidation=validate_anno(request.vars.incorso,request.vars.descrizione))
    response.view = 'private/write_anno.html'
    return dict(form=form,viewaction='create')*

And here the changes on the domain 

*db.define_table('anno',
    Field('descrizione',unique=True),
    Field('incorso','boolean'),format='%(descrizione)s')*


Web2Py the Best :)

-- 



Reply via email to