Sorry, I think I have asked the wrong question.

The whole idea:
Every user sees a lot of checkfields he can check or not.

But there is a administrator, which can allow these changes or disallow it
for every field independently. If a user is not allowed to change a
specific checkbox he should only see the checkbox

If there is a new record there could be a default value.

The number of checkboxes is variable, so these boolean fields have their
own table.
I thought I could use a grid or a smartgrid.

Now I have used a FORM and the controller sets, if necessary, "disabled".
It works as expected.

2012/1/21 Massimo Di Pierro <massimo.dipie...@gmail.com>

>
> It does not work because this db.t.f1 is a field (a column) not a
> value (true or false).
>

I used it only to describe my problem.

>
> I guess what you want is make the second field readable or writable
> depending on which record you are looking at. For example it makes no
> sense if you are inserting a new record, should the second field be
> editable or not?
>
> That requires that you do it in controllers for example:
>
> def edit_t():
>     record = db.t(request.args(0))
>     if record: db.t.f2.writable = record.f1
>     else db.t2.writable = true
>     form =  SQLFORM(db.t, record).process()
>     return dict(form=form)
>
>
>
> On Jan 20, 5:12 pm, Martin Weissenboeck <mweis...@gmail.com> wrote:
> > Hi,
> >
> > I want to have a model like
> >
> > db.define_table("t",
> >     Field('f1', 'boolean'),
> >     Field('f2', 'boolean', writable = db.t.f1),
> >   )
> >
> > Of course, this does not work, but how could it be written?
> >
> > Regards, Martin
>

Reply via email to