Q: I am making an sqlform widget with jquery sortable, to change the order of a list

13 views
Skip to first unread message

kk

unread,
Aug 22, 2015, 7:58:26 PM8/22/15
to web2py-users
Hi, I am making an sqlform widget that can change the order of a list, for example, if I have a field with value
xx = [a,b,c], 
user can interact with this ui to make it 
xx = [c, a, b].

To achieve this, I need to post a list. If I use SELECT, it is easy, but you cannot change the order of SELECT value. 
I googled, and found out that if you have multiple post values, they are treated as a list. For example, 
DIV(
HIDDEN(_value= 'a', _name='xx'), 
HIDDEN(_value= 'b', _name='xx'), 
HIDDEN(_value= 'c', _name='xx')) will post xx=[a,b,c], and
DIV(
HIDDEN(_value= 'c', _name='xx'), 
HIDDEN(_value= 'a', _name='xx'), 
HIDDEN(_value= 'b', _name='xx')) will post xx=[c,a,b].

The problem happens when SQLFORM accepts the form. I saw that xx=[c,a,b] is posted, and found in request.post_vars and request.vars, but it disappears after SQLHTML.accepts() is executed. I narrowed down, and found that HTML._traverse() function for some reason does not think this is a value.

So I am stuck.

Any idea?
Reply all
Reply to author
Forward
0 new messages