It is OK, I use raw sql to do this thing.
id =
db.to_be_lawyer.update_or_insert(db.to_be_lawyer.user_id==form.record.id,
user_id=form.record.id, created_time=datetime.datetime.today())
response.flash = '已经申请,请等待通知!'
On 3月27日, 上午9时50分, web2py_lover <lia...@gmail.com> wrote:
> not work
>
> I write as
>
> db.to_be_lawyer.user_id.default = auth.user.id;
> db.to_be_lawyer.created_time.default =
> datetime.datetime.today()
> db.to_be_lawyer.user_id.readable = False
> db.to_be_lawyer.created_time.readable = False
> form_to_be_lawyer= SQLFORM(db.to_be_lawyer, buttons =
> [INPUT(_type='submit',_value="apply to be a lawyer")] )
>
> but the inputs about 'user_id' and 'created_time' still exist in
> SQLFORM when I show SQLFORM in html.
> I want to hide them in the view. How to ? Thanks all.
>
> On 3月26日, 下午8时04分, Alan Etkin <spame...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I think that the problem when doing fields=[] is that it tells web2py
> > to build a field-less form which has no meaning so far. gluon API
> > says: "...a list of fields that should be placed in the form...".
> > Instead, it's probably best to just use the db.table.field.readable
> > attribute
>
> > On 26 mar, 07:46, Alan Etkin <spame...@gmail.com> wrote:
>
> > > Is the buttons parameter documented somewhere?, I don't recall having
> > > seen it.
>
> > > Fields that have a readable attribute set to False cannot be seen:
>
> > > db.to_be_lawyer.name.readable = False
> > > ...
>
> > > The fields parameter of SQLFORM defaults to all, but passing an empty
> > > sequence should prevent all fields to show.
>
> > > On 26 mar, 07:31, web2py_lover <lia...@gmail.com> wrote:
>
> > > > How to hide all fields of SQLFORM with submit button only?
>
> > > > all fields of db.to_be_lawyer are 'name' and 'age'.
>
> > > > I try
> > > > db.to_be_lawyer.name.default = 'default name'
> > > > db.to_be_lawyer.age.default = '28'
> > > > form_to_be_lawyer= SQLFORM(db.to_be_lawyer, fields=[], buttons
> > > > = [INPUT(_type='submit',_value="apply to be a lawyer")] )
>
> > > > but fail.