Thank you for your advise,
You a correct, the return is wrong. Sorry about that.
Isn't "item" a method of dict?
when i try to name every form different, by saving them in a list, i get a
'list assigment index out of range'
without saving them in a list and naming evry form the same, no error
occurs, but my result looks like this:
{1: <gluon.html.FORM object at 0x074DF730>}, 1: {1: <gluon.html.FORM
object at 0x074F6190>}, 2: {1: <gluon.html.FORM object at 0x074F61D0>}}
i marked the changes i made in red:
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 = []
form = []
while i < names_in db:
form[i] = 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[i]]
names_in db_dict[i] = new_dict_element[]
i = i+1
if form[i].process().accepted: #Now
part of the while function
remove_id = form.vars.name
return dict (names_in_db = names_in_db_dict)
view:
{{=names_in_db_dict}}
#without the for function
Am Sonntag, 24. Januar 2016 19:08:48 UTC+1 schrieb Lucas Schreiber:
>
> 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 :)
>
>
--
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.