Okay, that explains the behaviour. How, then, are values usually preserved 
on an ajax form for the built-in widgets? When I submit the form all of the 
other fields (not using my widget) preserve the newly submitted values.

Ian

On Thursday, February 18, 2016 at 3:51:59 PM UTC-5, Anthony wrote:
>
> Hard to say without seeing more code, but note that the widgets are 
> constructed before any database IO, so any database changes from the 
> current submission will not be reflected in the returned copy of the form.
>
> Anthony
>
> On Thursday, February 18, 2016 at 3:40:32 PM UTC-5, Ian W. Scott wrote:
>>
>> I've got a custom select widget class that is working nicely except that 
>> when I submit a form via ajax the refreshed widget shows the old 
>> (pre-submission) field value. But the changes have been made properly to 
>> the database. If I refresh the page containing the form (not via ajax) the 
>> new correct value appears. It's just when the field is refreshed after ajax 
>> submission that the old value re-appears. To be clear, I
>>
>> 1. change the value for a field using my select widget
>> 2. submit the form via ajax (preserving the values normally)
>> 3. when the form refreshes my select widget shows the original (wrong) 
>> value
>> 4. I refresh the whole page and the select widget now shows the changed 
>> (correct) value
>>
>> I set up the widget (called AjaxSelect) like this:
>>
>> db.lemmas.extra_tags.widget = lambda field, value: AjaxSelect(field, 
>> value,
>>                                 
>>                                                              indx=1, 
>> multi='basic', lister='simple', orderby='tag'
>>                                                                              
>>                 
>> ).widget()
>>
>> I can't see where the problem is in my own code because the wrong value 
>> is received right when the AjaxSelect class is instantiated. There's 
>> obviously something about the process of preserving form values that I 
>> don't understand.
>>
>> Thanks,
>>
>> Ian
>>
>

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