So if form=SQLFORM.grid
Then form[0] is the shaded area with the search bar.
Likewise form[1] is the table with the data in it.
You could do form[1].append(whatever) or form[1].insert(-1, stuff).
form.process().accepted becomes form[1].process().accepted
If I recall correctly, form[1][0][1] is the table head row with the
column titles.
To confirm, you could do print form[1][0][1][0] right after the call
to grid in your controller.
i am trying to figure out the SQLFORM.grid from the source. The create and update forms are generated using SQLFORM and not crud.. my mistake thinking this was done by CRUD. I guess i will need to customize the form by passing form.create_form.append(whatever) .. is this the right way? .. i will try to figure it out. Please pardon me, i am just a self taught novice coder
is there a simpler way to just insert some extra elements like http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM . I tried this, but this throws up an error (I will check and get back)
It seems I recall that form.process() does not handle inserted fields.
Just something to look out for when you get to the next stage.
def users():
grid = SQLFORM.grid(db.auth_user)
if len(request.args)>1 and request.args[-2]=='new' and grid.create_form:
grid.create_form[0].insert(-1,TR( LABEL('User type:', _id='auth_user_user_type'), INPUT(_type="radio", _name="radio_user_type", _value="normal") + LABEL('Normal user', _id="auth_user_normal_user")))
grid.create_form[0].insert(-1,TR('', INPUT(_type="radio", _name="radio_user_type", _value="service") + LABEL('Service user', _id="auth_user_service_user")))
grid.create_form[0].insert(-1,TR('', INPUT(_type="radio", _name="radio_user_type", _value="producer") + LABEL('Producer user', _id="auth_user_producer_user")))
return grid
hi guys sorry to intrude, i have a problem here
hi guys sorry to intrude, i have a problem heredb.define_table('stock_status',Field('Date', 'datetime', default=request.now, writable=False),Field('SN'),Field('item_description'),Field('Quantity','integer'),Field('UOM'),Field('stockIN','integer'),Field('stockOUT', 'integer'),#Field('stock_at_hand','integer'),Field('assignment'))class MyVirtualFields(object):def total_price(self):return self.stock_status.Quantity + self.stock_status.stockIN - self.stock_status.stockOUTdb.stock_status.stock_at_hand.virtualfields.append(MyVirtualFields())