Hi

I want a drop down list that shows all the values from existing records AND
allows the user to add a new value if they want.

I have got something working using https://select2.org/ . But my approach
is questionable.

The problem i have is that when a new value is added and the form is
submitted, the widget code is called *before* the new value is persisted to
the database. So when the form reloads after successfully being processed,
the dropdown doesn't have the new item and so can't be displayed.

If i then reload the page the new item is included and all is well.

I got around this by delaying the creation of the Select2 dropdown. Instead
of the widget immediately building the Select2 it executes an AJAX call
which grabs the dropdown data and then builds it. Of course this is done
after the form has been accepted so it has the new entry and all works well.

Is this the best way to do it?

Or can i somehow set the widget **after** the form has been created?

Thanks
Andrew

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CACWMBMNVeBd_cU5NSKRBSnyGVxcqDrDRf%2BLnC%3DOqmxshqG7Byg%40mail.gmail.com.

Reply via email to