Hi,

I'm trying web2py and want to create a "product" database and forms.

-displaying all products
-displaying one (in detail) and
-creating a new product

works, but i have problems with the "edit/delete" part. It will show
the filled-out form when calling e.g. product/edit/2 , but submitting
the form won't update the record.
What am I doing wrong?

models/db.py looks like this:
-------------------
db.define_table('product',
    Field('added_at', 'datetime', default=request.now, readable=False,
writable=False),
    Field('title', 'string'),
    Field('ean', 'integer'),
    Field('brand', 'string'),
    Field('mpn', 'string'),
    Field('image', 'upload'),
    Field('description', 'text'),
    Field('cost_price', 'double'),
    Field('sell_price', 'double'),
    Field('asin', 'string'))

db.product.ean.requires = IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'product.ean')
db.product.title.requires = IS_NOT_EMPTY()
-------------------

controllers/product.py has this function:
-------------------
def edit():
    form = SQLFORM(db.product, request.args(0))
    return dict(form=form)
-------------------

and views/product/edit.html:
-------------------
{{extend 'layout.html'}}
<h1>{{=T("Edit product")}}</h1>
{{=form}}
-------------------

Hope you can help me,

Florian

Reply via email to