I believe this is and should be the correct behaviour.

form.accepts happens after form.vars.number=5 is set, thus it should
store in form.vars.number whatever is in the form, unless the field
was not in the form to begin with.


Massimo

On Feb 9, 9:25 pm, DenesL <denes1...@yahoo.ca> wrote:
> db.define_table('calls',
>   SQLField('number','integer'),
>   SQLField('created','datetime')
> )
>
> def indexC():
>   return dict()
>
> def updateC():
>   rows=db(db.calls.id==1).select()
>   form1=SQLFORM(db.calls,rows[0])
>   form1.vars.number=5
>   if form1.accepts(request.vars):
>     session.flash='form accepted!'
>     redirect(URL(r=request,f='index'))
>   elif form1.errors:
>     response.flash='please fix errors and re-submit'
>   return dict(form1=form1)
>
> Shouldn't updateC change the number of call with id==1 to 5?
>
> Actually, the value does not get changed in previous versions either,
> but the manual says:
>
> Prepopulating the form
>
> It is always possible to prepopulate a form using the syntax:
> form.vars.name='fieldvalue'
> Statements like the one above must be inserted after the form
> declaration and
> before the form is accepted, whether or not the field ("name" in the
> example)
> is explicitly visualized in the form.
>
> If you hide the number field using
> form1=SQLFORM(db.calls,rows[0],fields=['created'])
> then the number of the call with id==1 gets changed to 5.
>
> Maybe it is just a wording misunderstanding.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to