I think this is a misunderstading.
after
form=....
before
form.accepts
insert
print request.vars.docs_categ_id
# form.vars.docs_categ_id==request.vars.docs_categ_id
you will see that if you submit the form (click submit) the
docs_categ_id is there.
Perhaps what you want is to use it to automatically populate the field
in the new record. If this is the case you have to tell web2py about
it by moving the value in the form. Uncomment the line above and it
will do so.
Massimo
On Feb 2, 12:13 am, mdipierro <[email protected]> wrote:
> I tried this with trunk and I cannot reproduce the problem. Please
> email me your app and I will take a look.
>
> Massimo
>
> On Feb 1, 1:50 pm, ionel <[email protected]> wrote:
>
> > Sorry,
>
> > It doesn't work.
>
> > categ_id = 0
> > if vars_list.has_key('categ') :
> > categ_id = vars_list['categ']
>
> > form=SQLFORM(db.docs_book,
> > fields=['author','title','volume','editor','collection',
>
> > 'place','year','pages','number','keywords','language','isbn','comment'],
> > labels={'author' : T('Author:'), 'title' : T('Title:')},
> > hidden=dict(docs_categ_id=categ_id),
> > submit_button=T('Add'))
>
> > In the html file <input name="docs_categ_id" type="hidden" value="3" /
>
> > > is present.
>
> > ionel
>
> > On Feb 1, 2:07 pm, mdipierro <[email protected]> wrote:
>
> > > sorry. you also need the new gluon/html.py
>
> > > On Feb 1, 12:43 pm, ionel <[email protected]> wrote:
>
> > > > Ok, done.
> > > > But after that:
>
> > > > Traceback (most recent call last):
> > > > File "gluon/restricted.py", line 62, in restricted
> > > > exec ccode in environment
> > > > File "/home/web2py/site/web2py/applications/docs/controllers/
> > > > default.py", line 185, in <module>
> > > > File "gluon/globals.py", line 55, in <lambda>
> > > > self._caller=lambda f: f()
> > > > File "/home/web2py/site/web2py/applications/docs/controllers/
> > > > default.py", line 172, in add_book
> > > > if form.accepts(request.vars, session):
> > > > File "gluon/sqlhtml.py", line 294, in accepts
> > > > ret=FORM.accepts
> > > > (self,vars,session,formname,keepvalues,onvalidation)
> > > > TypeError: accepts() takes at most 5 arguments (6 given)
>
> > > > ionel
>
> > > > On Feb 1, 12:17 pm, mdipierro <[email protected]> wrote:
>
> > > > > can you get the gluon/sqlhtml.py and gluon/sql.py from trunk and see
> > > > > if the problem goes away?
>
> > > > > Massimo
>
> > > > > On Jan 31, 10:12 pm, ionel <[email protected]> wrote:
>
> > > > > > web2py Version 1.55.2 (2009-01-08 08:38:01)
> > > > > > Apache/2.2.9 mod_python/3.3.1 Python/2.5.2 mod_wsgi/2.3
>
> > > > > > On Jan 31, 10:54 pm, mdipierro <[email protected]> wrote:
>
> > > > > > > which version of web2py are you using?
>
> > > > > > > On Jan 31, 9:38 pm, ionel <[email protected]> wrote:
>
> > > > > > > > Thank you Massimo.
>
> > > > > > > > I already applied your solution.
> > > > > > > > I verified the request.vars.category_id content. It's "None".
>
> > > > > > > > ionel
>
> > > > > > > > On 31 Ian, 22:18, mdipierro <[email protected]> wrote:
>
> > > > > > > > > I am sure category_id is in request.vars.category_id
>
> > > > > > > > > accepts will not move it in form.vars.id it is not obvious
> > > > > > > > > that is
> > > > > > > > > what you want to do. Try
>
> > > > > > > > > form=SQLFORM(db.book,
> > > > > > > > > fields=['author','title'],
> > > > > > > > > hidden=dict(category_id=the_category_id),
> > > > > > > > > submit_button='Add')
> > > > > > > > > form.vars.id=request.vars.category_id
>
> > > > > > > > > Massimo
>
> > > > > > > > > On Jan 31, 8:19 pm, ionel <[email protected]> wrote:
>
> > > > > > > > > > I have the following example:
>
> > > > > > > > > > the_category_id = 1
>
> > > > > > > > > > form=SQLFORM(db.book,
> > > > > > > > > > fields=['author','title'],
> > > > > > > > > > hidden=dict(category_id=the_category_id),
> > > > > > > > > > submit_button='Add')
>
> > > > > > > > > > After submit, the field "category_id" has no content.
> > > > > > > > > > I verified the source code of my page. The value is there:
> > > > > > > > > > <input
> > > > > > > > > > name="category_id" type="hidden" value="1" />
>
> > > > > > > > > > I don't understand what is the problem.
>
> > > > > > > > > > Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---