Thanks for the advice. I changed my code, but I don't know if I'm on
the right track. Anyhow it doesn't work.

==in a model file==
db.define_table('input',
        Field('value', 'integer'))
class MyVirtualFields(object):
        def input_number(self):
                return self.input.value

==in a controller file==
def create():
        records = db().select(db.day.ALL, orderby=db.day.thedate)
        form = SQLFORM(db.input, fields=['value'])
        db.day.virtualfields.append(MyVirtualFields())
        return dict(form = form)
def deleterec():
        session.virtualfields.remove(MyVirtualFields())
        db.input.input_number.remove(MyVirtualFields())
        redirect(URL('create'))

==in create.html==
{{for record in records:}}
        {{session.virtualfields=record.virtualfields}}
        {{=record.value}} : [ {{=A(("Delete this record"),
_href=URL('deleterec'))}}



>On Jan 2, 10:36 pm, Kenneth Lundström <kenneth.t.lundst...@gmail.com> wrote:
> If you only want to display a number I guess virtual fields is what you
> need. Look at
>
> http://www.web2py.com/book/default/chapter/06?search=virtual#Virtual-...
>
> Kenneth
>
>
>
>
>
>
>
> > Hi,
> > In addition to the records that are submitted with a SQLFORM, I want
> > to give each record a specific "identification" number, so that the
> > first record has number=1 and so on:
>
> > ==from model/db.py==
> > db.define_table('input',
> >    Field('number', 'integer'),
> >    Field('value', 'integer'))
>
> > ...My problem is that I don't know how to automatically add the number
> > to this form:
> > form = SQLFORM(db.input, fields=['value'])
>
> > Thanks in advance for help.

Reply via email to