> > I am trying to do a read only view of my form using the elements() > method of the form; > > Although I cant seem to figure it out. > > I am doing the following > > in view.html > > {{for k in form.elements():}} > {{= k }} > > {{pass}} > > > Not quite the result i am looking for. > > I want to be able to while looping check to see if each field should be > displayed. > > (Yes I know I can set the property on the db.table ie readable/and > writable however I want to do it manually based on runtime) > You would have to loop through the containing elements for the input fields, which are TR's for table formstyles, DIV's for the divs formstyle, and UL's for the ul formstyle. The id of the containing element is of the form "table_field__row", so you can use that to identify each row. However, this is probably an overly complicated approach. Instead, you can set the readable and writeable attributes of the fields dynamically at runtime:
def mycontroller: db.mytable.field1.readable = False form = SQLFORM(db.mytable, readonly=True) etc. Anthony