hi, and thanks for the reply. you gave some good options. __ i'm hesitant to go to the jquery method unless it's a last resort, because resorting to javascript here seems like a workaround. __ i tried doing the simplest, which i figured was removing the hidden field and putting this: request.vars['hiddenfield'] = val immediately before the form.accepts part. i could confirm that it set properly and that request.vars found hiddenfield, but it still wouldn't update (even if i set db.table.hiddenfield.writable=True).
something seems wrong there. is that by design? it was not a part of the sqlform but it becomes a part of request.vars immediately before the if form.accepts(request.vars, session), so i don't understand why it would be left behind. __ next i tried was your suggestion about processing the field manually in the "if form.accepts" part. the problem i'm finding is that form.accepts returns True or False rather than [id] or False. so i did this: a=form.accepts(request.vars,session) if a: ... but when i printed a, it printed not as 1 or 2 but as True. so it doesn't seem to be returning the identity that i would need in order to process an update. am i missing something there? __ lastly, i tried massimo's suggestion of setting the writable to false, creating the form, and setting the writable to true. unfortunately, that still didn't make the hidden field get processed. i tried making the field not hidden and what that did was print out to the user: hiddenfield: None __ so i know i can use jquery to hide it and i'm willing to do that, but it seems there should be a way to accomplish what i'm looking to do server-side. i'm open to the idea that i'm doing something wrong, as i'm still a relative newbie with web2py. thank you for the help so far and i look forward to hearing what's out there. matt On Aug 3, 5:59 am, Fran <francisb...@googlemail.com> wrote: > On Aug 2, 9:19 pm, mattynoce <mattyn...@gmail.com> wrote: > > > hi, i have a question about hidden fields. > > i have a form that looks like this: > > fields=['f1','f2','f3'...] > > hidden=dict(fieldname=val) > > form = SQLFORM(db.table, fields=fields, showid=False, hidden=hidden) > > in the view it's simply {{=form}} > > when i look at the view, there's a hidden input field for my hidden > > field. however, when i do the insert, the hidden field is not getting > > inserted into my db. the accept info is: > > if form.accepts(request.vars,session): > > session.flash='Added' > > redirect(URL(r=request, f="function")) > > am i doing something wrong? why would the hidden field show up > > properly in the view but not update the db? > > Hi Matt, > > I didn't know about this functionality before as it's not a documented > option in the docstring for SQLFORM (or FORM), but I see it in the > manual now. > > Looking at the code in sqlhtml.py, it seems that the hidden fields > aren't processed by SQLFORM itself...I guess this is a design rather > than a bug (the hidden fields would normally be for other things than > DB fields). > > You have several options to achieve what you want, including: > (1) Process this field manually in the 'if form.accepts' part > (2) Don't pass the field as hidden to 'form' but instead use jQuery to > hide the row (default value can be set within model or by jQuery) > (3) Follow Massimo's suggestion: > db.table.hidden_field.writable = False > form = SQLFORM(db.table, fields=fields, showid=False, hidden=hidden) > db.table.hidden_field.writable = True > if form.accepts(request.vars,session): > > Best Wishes, > Fran. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" 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 -~----------~----~----~----~------~----~------~--~---