I end up compare with a big if form.vars value to default value used to
populate the update form that I had available...

Thanks

Richard

On Tue, Dec 6, 2016 at 8:23 PM, Richard Vézina <[email protected]>
wrote:

> I was searching for a way to detect records change in a complexe
> sqlform.factory used to populate multiples tables and multiples rows in one
> of them... Until now, I have been able to manage the insertion and update
> with the help of update_or_insert()... For instance if some of the input
> change state (dropdown select displays in a table) there is no problem if
> there is still a selected value, but if the one previously selected value
> are now unselected there is no way update_or_insert() would be able to
> delete the proper row as form.vars.select1_field_name = None and record
> can't be retrieve...
>
> The snippet propose by Massimo would have been exactly what I am searching
> for, but I am not sure record_id can be pass in context of .factory() as it
> make no sens in my use case...
>
> I need to know what was the value of the update form before user submit
> it... Is this this information kept by form and available some how with
> request or other mean?
>
> Richard
>
> On Sun, Dec 9, 2012 at 1:41 PM, Massimo Di Pierro <
> [email protected]> wrote:
>
>> Something like this?
>>
>> form=SQLFORM(db.table,record_id)
>> if form.process(dbio=False).accepted:
>>     if any(v!=form.record[k] for k,v in form.vars.iteritems()):
>>        record_has_changed
>>     else:
>>        record_has_NOT_changed
>>
>>
>> On Sunday, 9 December 2012 10:51:14 UTC-6, Joe Barnhart wrote:
>>>
>>>
>>> I've been investigating the use of the DAL feature
>>> "detect_record_change=True".  Apparently it was conceived as a way of
>>> detecting when the record in the database has changed since the form was
>>> originally built and populated.  My need is for a way to detect when the
>>> USER has changed fields in the record between the time it was built and
>>> some other event, such as when the user tries to navigate away from the
>>> form without pressing the "submit" button.
>>>
>>> It seems to me the idea is quite similar -- I want to serialize the data
>>> in the form and then compare that hash to the same form later.  Only
>>> instead of comparing the data in the database to the hash I want to compare
>>> the form's version of the data again.  Has anyone already done this?  Is
>>> there a better way to detect when a form has actually been changed instead
>>> of just viewed?
>>>
>>> -- Joe B.
>>>
>> --
>>
>>
>>
>>
>
>

-- 
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