process() does the insert for you (that's the whole point of having a *SQL*FORM).
If you need to manage the insert/delete/update in your own way, you need to http://web2py.com/books/default/chapter/29/07#SQLFORM-without-database-IO PS: you said over and over to be a newbie and to have looked at the book, but it seems to me that you need to look at it at least another time. On Monday, February 25, 2013 6:25:15 PM UTC+1, 黄祥 wrote: > > hi, > > i found a problem during entry in sqlform, the data that i've submit is > double entry to database : > > for example: > *###default.py* > def sale(): > rows=db((db.product.quantity>0)).select(orderby=db.product.id, > cache=(cache.ram, 10)) > form = SQLFORM(db.sale) > * if form.process(session=None, formname='sale').accepted:* > * db.sale.insert(invoice_no=request.vars.invoice_no,* > * product=request.vars.product,* > * quantity=request.vars.quantity,* > * unit_price=request.vars.unit_price,* > * > total_price=int(request.vars.quantity)*int(request.vars.unit_price),* > * grand_total=request.vars.grand_total)* > elif form.errors: > response.flash = 'form has errors' > else: > response.flash = 'please fill the form' > # Note: no form instance is passed to the view > return dict(rows=rows) > > *###default/sale.html* > {{extend 'layout.html'}} > > <form action="" enctype="multipart/form-data" method="post"> > <table width="100%"> > <tr> > <th>Invoice No.</th> > <th>Product</th> > <th>Quantity</th> > <th>Unit Price</th> > <th>Total Price</th> > <th>Grand Total</th> > </tr> > <tr> > <td> > <input class="string" id="sale_invoice_no" name="invoice_no" > type="text" value="" size="9" /> > </td> > <td> > <select class="generic-widget" id="sale_product" name="product"> > {{for i,row in enumerate(rows):}} > <option value="{{=row.id}}">{{=row.product_name}}</option> > {{pass}} > </select></td> > <td> > <input class="integer" id="sale_quantity" name="quantity" > type="text" value="" size="9" /> > </td> > <td> > <input class="decimal" id="sale_unit_price" name="unit_price" > type="text" value="" size="9" /> > </td> > * <td>* > * <input class="decimal" id="sale_total_price" name="total_price" > type="text" value="" size="9" />* > * </td>* > <td> > <input class="decimal" id="sale_grand_total" name="grand_total" > type="text" value="" size="9" /> > </td> > </tr> > <tr> > <td><input type="submit" value="Submit" /> > <input type="hidden" name="_formname" value="sale" /></td> > </tr> > </table> > > </form> > > the data in database table is produce 2 value: > 1. the data in form for total price (request.vars.total_price) > 2. the data that is calculate for total_price (quantity * unit_price) > > is there any possiblity to prevent that? > > thank you very much before. > -- --- 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/groups/opt_out.

