Send args from a button in views

56 views
Skip to first unread message

Matthew J Watts

unread,
May 24, 2018, 9:46:05 AM5/24/18
to web2py-users
Hi all

How do i  send args via a button from views. 

For example, i'd like to send variables to the 'my_collections URL'  {{=A('Finish',_href=URL('my_collections'),_class="btn btn-primary")}}

I can do something similar from the grid in a controller, however i cant find the right way to it from a button in views

links = [lambda row: A('Select', _class="btn btn-primary",_href=URL('my_collections'),
vars={'collection_info_id': collection_info_id}))]

isi_jca

unread,
May 24, 2018, 5:13:41 PM5/24/18
to web2py-users


Matthew:

Look at the example in the attached file

Regards



grid_link.txt

黄祥

unread,
May 24, 2018, 6:30:37 PM5/24/18
to web2py-users
pls try (not tested)
{{=A('Finish',_href=URL('my_collections/%s/%s', % ('args0', 'args1') ),_class="btn btn-primary")}}
or 
{{=A('Finish',_href=URL('my_collections', args = ['args0', 'args1'] ),_class="btn btn-primary")}}

best regards,
stifan

Sandeep Patel

unread,
May 26, 2018, 2:22:03 AM5/26/18
to web...@googlegroups.com
@Matthew J Watts
You can try this
grid = SQLFORM.grid(query,selectable=[('Name',lambda ids :redirect(URL('default','func',args=ids)))])


best
sandeep

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew J Watts

unread,
May 26, 2018, 5:48:43 AM5/26/18
to web...@googlegroups.com
Thanks for your help all!
 i'll give these a go. Sorry if i want that clear, but i'm not trying to use a grid, i'm trying to redirect from a button in views
<div class="btn-group">
{{=A('Cancel',_href=URL('my_collections'),_class="btn btn-primary")}}
</div>


You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/jtzQVBzQU6Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Sandeep Patel

unread,
May 26, 2018, 9:48:01 AM5/26/18
to web...@googlegroups.com
@Matthew J Watts
That is my fault, I apologized for my mistake

If you are trying to redirect one view to another view page.

you can try this
<div class="btn-group">
<a href="/{{=request.application}}/{{=request.controller}}/your func name/{{=args witch you want to use}}" class="btn btn-primary">Cancle</a>

</div>
maybe that's some help you

Thanks
sp

Matthew J Watts

unread,
May 26, 2018, 10:59:45 AM5/26/18
to web...@googlegroups.com
Great thanks Sandeep!
Reply all
Reply to author
Forward
0 new messages