What is the traceback? Is this an OperationalError or  RuntimeError.
It is possible that the database does not like the field name 'uid'. I
do not think this is a web2py error.

On Jan 15, 11:35 am, kbochert <kboch...@copper.net> wrote:
> No good.
>
> It hides the field correctly but again after:
>     form.vars.uid = 2 # set the uid explicitly
> the call
>     db.client.insert(**dict(form.vars))
> complains that 'uid' is an invalid field name
>
> It appears that SQLFORM is just not prepared to accept a field that
> it didn't display.
>
> Karl
>
> On Jan 15, 9:18 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > You can change
>
> > db.client.uid.readbale=True or False
>
> > where you need it, for example in the action before form=.
>
> > Massimo
>
> > On Jan 15, 11:08 am, kbochert <kboch...@copper.net> wrote:
>
> > > Is it possible to use SQLFORM to generate forms which show different
> > > fields?
>
> > > I.E. I have a model:
>
> > > db.define_table('client',
> > >     Field('uid', auth_user),
> > >     Field('name', 'string'),
> > >     migrate = 'client.table'
> > >     )
>
> > > I want a page which the client uses that hides the 'uid' field, which
> > > gets filled in automatically by the controller.
> > > A different page accessible to the superuser shows the field normally.
>
> > > I tried:
> > > db.define_table('client',
> > >     Field('uid', 'string', readable=False, writable=False),
> > >     Field('name', 'string'),
> > >     migrate = 'client.table'
> > >     )
>
> > > with
> > >     form = SQLFORM(db.client, _id='profile_table')
> > >     if form.accepts(request.vars, session, dbio=False):
> > >         form.vars.uid = 2
> > >         form.vars.id = db.client.insert(**dict(form.vars))
>
> > > and get the error
> > >     SyntaxError: invalid field names: ['uid']
>
> > > The other approach I tried was to remove the 'readable' and 'writable'
> > > from the model (But won't those prevent the superuser's page from
> > > showing the 'uid' field??) and using the 'fields' parameter in the
> > > SQLFORM call to explicitly set the fields I wanted to see.  Same
> > > result- the accepts() method rejects the added 'uid' var.
>
> > > Finally I tried using the 'onvalidation' parameter.  Same result.
>
> > > Is there a way to do this??
> > > Karl
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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