I have created a custom web2py form to allow the user to edit a current
record. However when the user submit the record update I receive the
following error message:
<class 'TypeError'> list indices must be integers or slices, not str
What am I missing?
Here is an excerpt from the appliance I am building
Model
db.define_table('phase',
Field('id', 'integer', writable=False, readable=False,
widget=SQLFORM.widgets.integer.widget),
Field('pname', 'string', unique = True, label='Phase',
widget=SQLFORM.widgets.string.widget), format='%(pname)s')
Validators
db.phase.pname.requires = IS_NOT_EMPTY(error_message='Please select a valid
name')
Controller
def ephase():
# Receive the value from the form
id = request.vars['id']
form = SQLFORM(db.phase, id).process()
if form.process().accepted:
reponse.flash = 'new record inserted'
elif form.errors:
response.flash = form.errors.name
return dict(form=form)
View
{{=form.custom.begin}}
{{=form.custom.widget.id}}
{{=form.custom.widget.pname}}
{{=form.custom.submit}}
{{=form.custom.end}}
--
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.