Solved in some extend: The problem is that each widget is initialized with the record values on the SQLFORM constructor if any, in the case you need to pre-populate the form (http://web2py.com/books/default/chapter/29/07/forms-and-validators#Pre-populating-the-form) it work flawless for all the other fields except for 'list:string', in my case the 'keywords' field.
I'm getting around the problem using defaults, in the controller: def edit(): item = db.item(request.args(0)) concrete_item = db.concrete_item(item_id=item.id) fields = [] # before adding the the fields db.item.keywords.default = item.keywords # --- for f in item: fields.append(f) for f in concrete_item: fields.append(f) form = SQLFORM.factory(*fields) # put values to form fields for f in db.item: form.vas[f.name] = item[f.name] for f in db.concrete_item: form.vas[f.name] = concrete_item[f.name] if form.proccess().accepted: # here call update_record, etc. pass return dict(form=form) El lunes, 29 de agosto de 2016, 14:24:19 (UTC-4), Yoel Benitez Fonseca escribió: > > h! > > i got 2 tables, i need to make one update form for both, let's say they > are: > > --------- > db.define_table("item", > ... > Field('keywords', 'list:string', ...) > ... > ) > db.define_table('concrete_item', > Field('item_id', 'reference item'), > ... > ) > > > --------- > In the controller: > --------- > def edit(): > item = db.item(request.args(0)) > concrete_item = db.concrete_item(item_id=item.id) > fields = [] > for f in item: > fields.append(f) > for f in concrete_item: > fields.append(f) > > form = SQLFORM.factory(*fields) > # put values to form fields > for f in db.item: > form.vas[f.name] = item[f.name] > for f in db.concrete_item: > form.vas[f.name] = concrete_item[f.name] > > if form.proccess().accepted: > # here call update_record, etc. > pass > > return dict(form=form) > > > --------- > > The problem is with the keywords field, when the form is rendered in the > view it don't show the current value for the field. Meanwhile if i just > make the update form for only one table: > > -------- > def edit() > item = db.item(request.args(0)) > > form = SQLFORM.factory(db.item, record=item) > return dict(form=form) > > > -------- > > The keywords field show the current values. Can any1 help me with this ? > > -- > Yoel BenÃtez Fonseca > http://redevil.cubava.cu/ > $ python -c "import this" > -- 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. For more options, visit https://groups.google.com/d/optout.