i hid the field in the table because it's a foreign key that the user
shouldn't adjust. for example, say the user has clicked on a category
and is adding an item. the db looks like this:

category: bunch of fields
item: id, categoryid, name, bunch of fields

so when they click on "category 1", it takes them to:
/init/default/additem/1
where 1 is the categoryid.

when the item is added, it needs to insert that categoryid into the
item table. so i put a hidden field of categoryid in the table,
expecting that it would update. it updates name and all other fields,
but not categoryid.

the field categoryid is writable -- if i take it out of hidden and put
it in the field listing, it works perfectly. except that i don't want
the user to be able to adjust it.

so i tried looking for "writable" on this forum and found only
db.table.field.writable. if i'm using sqlform instead of individual
sqlfields, how would i set that hidden field to writable so that the
database will accept it?

i'm sorry if this is simple, i just haven't been able to find the
answer.

thanks,

matt

On Aug 2, 5:16 pm, mdipierro <[email protected]> wrote:
> I assume those fields corresponds to fields in the table but are
> hidden because writable=False.
> You need to set writable=True after the form is created, before the
> form is accepted.
>
> If web2py thinks they are not writable will not allow a client to
> write in them, as a security measure.
>
> Massimo
>
> On Aug 2, 3:19 pm, mattynoce <[email protected]> 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?
>
> > thanks,
>
> > matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to