On Sunday, January 24, 2016 at 10:08:48 AM UTC-8, Lucas Schreiber wrote:
>
> Hey, 
> i would like to save some values in a dict and give them out together with 
> a form. it should look something like this:
> ([] marks a button, the name n are the values, and links)
>
> name1   [Remove?]
> name2   [Remove?]
> name3   [Remove?]
> .
> .
> .
> name n [Remove?]
>
>
> my idea looks like this:
>
> [code]
> controller:
>
> def test():
>
> names_in db = db(db.names.group_2 == group).count()
> names_in db_row = db(db.names.group_2 == group).select(dba.names.ALL)
> i = 0
> names_in db_dict = {}
>
> new_dict_element = []
> while i < names_in db:
>
>     form = FORM('',
>
>             INPUT(_name='name', _value=i, requires=IS_NOT_EMPTY()),
>             INPUT(_type='submit'))
>
>     current_name =names_in db_row[i].group_2
>
>     new_dict_element.append[current_name] 
>
>     new_dict_element.append[form]
>     names_in db_dict[i] = new_dict_element[]
>     i = i+1
>
> if form.process().accepted:
>
>    remove_id = form.vars.name
>
>   return dict (names_in_db = names_in_db) 
>
>
>
> view:
>
>
> {{=for item in names_in_db}}{{=item}}
>
>
> [/code]
>
>
> is dict the proper type for this? why isn't it working?
>
> thank you alot guys :)
>
>

The dictionary you're returning just has your count, doesn't it?  And where 
does the view find "item"?

Secondly, the multiple forms each need to have a separate name, or the 
buttons won't know what they belong to.

Thirdly, it usually is easier to use SQLFORM for this (which takes care of 
having the rows all displayed, and can handle the remove button,  Unless 
there is some additional special reason for the way you are doing things, 
I'd look into SQLFORM.

/dps
 
 

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