Try this:
def test2():
posts=db(db.papers.id > 0).select()
def writable(id):
condition = not posts.find(lambda r: r.id==id).printout
chkposts=[Field('pst_
%s'%pst.id,requires=condition,label=pst.printdate, writable=condition)
for pst in posts]
form=SQLFORM.factory(*chkposts)
if form.accepts(request.vars, session):
response.flash = 'form accepted'
return dict(form=form)
On Jul 26, 1:09 pm, KMax <[email protected]> wrote:
> Hello
> I had table defined:
> db.define_table('papers',
> Field('printdate','date'),
> Field('printout','boolean',default=False))
>
> So I need FORM with checkboxes for each printdate, but if printout for
> particular date gets 'True' (mean to app user 'CLOSED FOR ACCEPT NEW
> POST' ) error message printed.
>
> def test2():
> chkposts=[]
> posts=db(db.papers.id > 0).select()
> for pst in posts:
>
> chkposts.append(DIV(INPUT(_type='checkbox',_name='pst_'+str(pst.id),requires=IS_IN_DB(db((db.papers.id
> ==MY_QUESTION )&(db.papers.printout == False)),'papers.id','%
> (name)s',error_message=T('CLOSED FOR ACCEPT NEW
> POST'))),str(pst.printdate)))
> chkposts.append(INPUT(_type='submit',_value='SUBMIT'))
> form=FORM(*[chkposts[num] for num in
> range(len(chkposts))],_name="adcr")
> if form.accepts(request.vars, session):
> response.flash = 'form accepted'
> return dict(form=form)
>
> What should I put instead MY_QUESTION to IS_IN_DB get work? I want
> alert on checkbox who corresponding to records with
> db.papers.printout==True
> But checkbox return "on" value and I need name of checked checkbox
> modifyed by .split('_')[-1] -ed
>
> Please advise.
>
> Thank you.
> --
> Maxim