Model please!

I would see you lambda computed field.

Richard

On Thu, Apr 19, 2012 at 4:09 PM, simon <[email protected]> wrote:

> See below. The age field is read only and the form is already created when
> you do the accept. So to get the updated age I recreate the form with the
> new data. It does work though I think it would have been neater to have the
> age as a compute field in the model.
>
> def onvalidation(form):
>     """ calculates fields before update """
>     form.vars.age=calc.age(form.vars.date_of_birth)
>
> def edit():
>     customer=db.customer[request.args(0)]
>
>     form = SQLFORM(db.customer, customer)
>     if form.process(onvalidation=onvalidation).accepted:
>         # recreate form with calculated fields
>         customer=db.customer[request.args(0)]
>         form = SQLFORM(db.customer, customer)
>
> On Thursday, 19 April 2012 20:59:39 UTC+1, Richard wrote:
>>
>> What do you mean by reread and recreate?? You create a record, you update
>> (modify) a record and you read a record.
>>
>> What behavior is not correct, I think also, we would need to see your
>> code, maybe you have some error in your code that bring you to think that
>> it is not working as expect.
>>
>> Richard
>>
>

Reply via email to